Rsync examples

Category: Note to Self

To rsync between 2 hosts you should have a public key to allow password-free login

Example 1: Copy all files to remote folder

rsync -avz -e ssh /source/path/  remoteuser@remotehost.com:/remote/folder/

Example 2:  rsync operation deleting files on the remote side that do not exist on local:

rsync -azv --delete -e ssh /source/path/ remoteuser@remotehost.com:/remote/folder/

Example 3:  exclude specified files from operation

rsync -azv --delete -e --exclude 'Thumbs.db' --exclude '.DS_Store' /source/path/ /destination/folder/