rsync command options
- z - compress data (faster transfer)
- v - verbose
- r - recurse into directories
upload files
rsync -zvr ./ username@192.168.0.1:/home/username/websites/ |
upload files and show the progress
rsync -zvr --progress ./ username@192.168.0.1:/home/username/websites/ |
delete files that don't exist in the local copy
rsync -zvr --delete ./ username@192.168.0.1:/home/username/websites/ |
upload files but exclude some files and directory
we want to exclude all files starting with a dot ., and a directory named node_modules.
rsync -zvr --exclude=".*/" --exclude node_modules/ ./ username@192.168.0.1:/home/username/websites/
rsync options can be used together
rsync -zvr --delete --progress --exclude=".*/" --exclude node_modules/ ./ username@192.168.0.1:/home/username/websites/ |
use a public key (.pem file) with rsync
rsync -zvr -e "ssh -i server-key.pem" ./ username@192.168.0.1:/home/username/websites/ |
download files
rsync -zvr --progress --exclude=".*/" username@192.168.0.1:/home/username/websites/ ./ |
rsync with progress on Mac OSX
rsync --progress --size-only --delete --exclude=".DS_Store" -r -v -e ssh /Users/username/views/ username@192.168.0.1:/data/views/ |
note
If you are using scp or rcp, it is high time you switched to rsync - because rsync was written specifically to replace them.