1. MagicESP
  2. Ubuntu Server 22.04
  3. SSH Transfer Files Using tar

SSH Transfer Files Using tar

tar can be used to fast transfer files between two Ubuntu servers.

Push Directory from Server A to Server B (same path)

The following files/directories in Server A will be excluded:

sudo tar -c {{ path.value }} | ssh {{ b_hostname.value }} 'sudo tar -xvf - -C /'

parallel by directories (same path)

sudo apt install parallel
find {{ path.value }} -type d -maxdepth 1 | parallel --will-cite --dry-run -j {{ job.value }} sudo tar -c {} \| ssh {{ b_hostname.value }} 'sudo tar -xvf - -C /'
find {{ path.value }} -type d -maxdepth 1 | parallel --will-cite -j {{ job.value }} sudo tar -c {} \| ssh {{ b_hostname.value }} 'sudo tar -xvf - -C {} -C /'
不需要
find {{ path.value }} -type d -maxdepth 1 | parallel --will-cite -j {{ job.value }} ssh {{ b_hostname.value }} 'sudo mkdir -p {}'