copying files with rsync

rsync is a great way to copy files between computers as it can continue after partial copies and update directories when only a few files have changed, it also supports secure file copies over ssh as shown below:

copy files locally:

rsync -rtvzP --delete --exclude=.Trash /Users/evan/ /Volumes/backup/evan/

copy local files to a remote computer excluding all the mac .DS_Store folders in the path:

rsync -ravzP --exclude=**/.DS_Store -e ssh "/Users/evan/my files/" evan@someserver.codepit.ca:/home/evan/files/

copy remote files onto a local computer:

rsync -ravzP -e ssh 10.10.238.123:"/home/evan/my files/" /Users/evan/files/

NOTE the use of " when there is are spaces in the file paths

Useful switches:

-n == dry run, very useful with --delete :o
--delete == delete files when they are missing from the source computer and present on the target