rsync basics

rsync basics

A common use
$ rsync -azv -e "ssh -p 22" user@remote-host:/path/to/origin/ /path/to/destination

Sync the directory destination in the local host with the contents of the directory origin in the remote-host over SSH.

Common Options
 -v, --verbose            increase verbosity
 -a, --archive            archive mode; equals -rlptgoD (no -H,-A,-X)
 -z, --compress           compress file data during the transfer
 -e, --rsh=COMMAND        specify the remote shell to use 

-a expansion
 -r, --recursive          recurse into directories
 -l, --links              copy symlinks as symlinks
 -p, --perms              preserve permissions
 -t, --times              preserve modification times
 -g, --group              preserve group
 -o, --owner              preserve owner (super-user only)
 -D                       same as --devices --specials
 --specials               preserve special files
 --devices                preserve device files (super-user only)

Other Useful options-flags
 -n, --dry-run           perform a trial run with no changes made

 -P                      same as --partial --progress
 --progress              show progress during transfer
 --partial               keep partially transferred files

 --delete                delete extraneous files from dest dirs

 --exclude-from=FILE     read exclude patterns from FILE
 --exclude=PATTERN       exclude files matching PATTERN

Note that,
$ rsync -azv -e "ssh -p 22" user@remote-host:/path/to/origin /path/to/destination
without the slash after origin would create a copy of the directory user@remote-host:/path/to/origin
in the directory /path/to/destination
like /path/to/destination/origin

rsync basics