Rsync Examples

Posted

A few examples of how I use rsync to copy files between hosts and drives.

basic local sync:

rsync -hrtP /path/to/source/ /path/to/destination/

sync remote to local:

rsync -hrtP user@remote.com:/home/user/files/ /home/user/files/

sync local to remote:

rsync -hrtP /home/user/files/ user@remote.com:/home/user/files/

custom ssh port:

rsync -hrtP -e "ssh -p 4220" /home/user/files/ user@remote.com:/home/user/files/

Explanation of Arguments


Additional Arguments to Consider

--delete

To delete anything found in the destination, which is not found in the source, add --delete to the end of your command.

--dry-run

To perform a dry-run which only logs the results without actually changing anything, add --dry-run to the end of your command.