Transfer files from one server to another using rsync
I needed to transfer 10.000 images from one server to another, so I used rsync for this task:
rsync -ahuzP --stats -e "ssh -p 4721" "/var/www/img" root@example.com:/var/www/
This will copy the folder /var/www/images
and all of its contents from the local server to the remote server example.com
. The folder /images
will be created in the target’s /var/www/
directory. I specified a non-standard SSH port using the -e
parameter and root
as user. I also used the following rsync parameters:
-a, --archive archive mode; equals -rlptgoD (no -H,-A,-X)
-v, --verbose provide more information during transfer
-h, --human-readable output numbers in a human-readable format
-u, --update skip files that are newer on the receiver
-z, --compress compress file data during the transfer
-P same as --partial --progress
--stats give some file-transfer stats
See http://explainshell.com for a full explanation of what the command does.