Common Usage
Here is common usage,
rsync --archive --delete --sparse --compress --verbose --progress /home/tempadmin/tmp/source /home/tempadmin/tmp/destination
--archive
Same as -rlptgoD (no -H)
This is equivalent to recursive, links, perms, times, group, owner, specials. It is a quick way of saying you want recursion and want to preserve almost everything (with hard-links being a notable omission). The only exception to the above equivalence is when --files-from is specified, in which case -r is not implied.
--owner
This option causes rsync to set the owner of the destination file to be the same as the source file, but only if the receiving rsync is being run as the super-user (see also the --super option to force rsync to attempt super-user activities). Without this option, the owner is set to the invoking user on the receiving side.
The preservation of ownership will associate matching names by default, but may fall back to using the ID number in some circumstances (see also the --numeric-ids option for a full discussion).
--group
This option causes rsync to set the group of the destination file to be the same as the source file. If the receiving program is not running as the super-user (or if --no-super was specified), only groups that the invoking user on the receiving side is a member of will be preserved. Without this option, the group is set to the default group of the invoking user on the receiving side.
The preservation of group information will associate matching names by default, but may fall back to using the ID number in some circumstances (see also the --numeric-ids option for a full discussion).
--delete
Delete extraneous files from destination directories.
--sparse
Try to handle sparse files efficiently so they take up less space on the destination. Conflicts with --inplace because it's not possible to overwrite data in a sparse fashion. NOTE: Don't use this option when the destination is a Solaris "tmpfs" filesystem.
--compress
Compress files during transfer. For images, media or any other already compressed files do not compress as you just slow things down.
Special Use
-W -
--inplace
This option is useful for transfer of large files with block-based changes or appended data, and also on systems that are disk bound, not network bound.
On the Mac OS X to backup iPhoto,
rsync --extended-attributes -perms --owner --group --links --recursive --delete --times --verbose --progress --compress --sparse /home/tempadmin/tmp/source /home/tempadmin/tmp/destination
--extended-attributes = Copy extended attributes and resource forks
Over SSH
rsync ....
# Rsync over the Internet rsync --archive --verbose --compress --delete --progress -e "ssh -c arcfour -o Compression=no -x" /source/folder remotebackup@earth.com:/home/user:destination-folder # Rsync over LAN # Same but disable all compression.
--archive or -a = Archive mode. Performs recursion and preserves almost all attributes of the source files (with -H being a notable omission). Note that it does not preserve hard links, because finding multiply-linked files is expensive. You must separately specify -H.
-v = Verbose. Using -vv will provide additional detail. Additionally more v's may be added.
-e ssh = Specify remote shell to be ssh.
-c arcfour = uses the weakest but fastest encryption that ssh supports.
-o Compression=no = Disable ssh compression as we will be using rsync's own which is more efficient.
--compress or -z = Enable rsync's compression.
-x = turns off ssh's X tunneling feature (if you have it on by default).
--dry-run or -n = Very important to use first time or to test --delete. Performs trial run without making changes. Use in combination with -v and --itemize-changes. -vv will provide even more details.
--delete or -d = Delete on target to match source.
--itemize-changes or -i = List of changes for each file including attribute changes.
--human-readable or -h = Makes numbers in the log and stdout more readable when it comes to large units.
--progress = Shows progress of transfer. Make sure not to use when using cron.
Command Reference
Remote file copy - Synchronize file trees across local disks, directories or across a network.
Syntax Local file to Local file: rsync [option]... Source [Source]... Dest Local to Remote: rsync [option]... Source [Source]... [user@]host:Dest # rsync [option...] [user@]host::Source... [Dest]
rsync [option...] rsync://[user@]host[:PORT]/Source... [Dest] Remote to Local: rsync [option]... [user@]host:Source... [Dest] # rsync [option]... [user@]host::Dest rsync [option]... rsync://[user@]host[:PORT]/Dest # = via remote shell rather than the rsync daemon
OPTIONS SUMMARY
Here is a short summary of the options available in rsync.
Please refer to the FULL List of OPTIONS for a complete description.
What to copy: -r, --recursive recurse into directories -R, --relative use relative path names --exclude=PATTERN Exclude files matching PATTERN --exclude-from=FILE Read exclude patterns from FILE -I, --ignore-times Don't exclude files that match length and time --size-only only use file size when determining if a file should be transferred --modify-window=NUM Timestamp window (seconds) for file match (default=0) --include=PATTERN Don't exclude files matching PATTERN --include-from=FILE Read include patterns from FILE How to copy it: -n, --dry-run Perform a trial run with no changes made -l, --links Copy symlinks as symlinks -L, --copy-links Transform symlink into referent file/dir --copy-unsafe-links Only "unsafe" symlinks are transformed --safe-links Ignore links outside the destination tree -H, --hard-links Preserve hard links -D, --devices Preserve devices (super-user only) -g, --group Preserve group -o, --owner Preserve owner (super-user only) -p, --perms Preserve permissions -t, --times Preserve times -S, --sparse Handle sparse files efficiently -x, --one-file-system Don't cross filesystem boundaries -B, --block-size=SIZE Force a fixed checksum block-size (default 700) -e, --rsh=COMMAND Specify rsh replacement --rsync-path=PATH Specify path to rsync on the remote machine --numeric-ids Don't map uid/gid values by user/group name --timeout=TIME Set IO timeout in seconds -W, --whole-file Copy whole files, no incremental checks Destination options: -a, --archive Archive mode -b, --backup Make backups (see --suffix & --backup-dir) --backup-dir=DIR Make backups into this directory --suffix=SUFFIX Override backup suffix -z, --compress Compress file data during the transfer -c, --checksum Skip based on checksum, not mod-time & size -C, --cvs-exclude Auto ignore files in the same way CVS does --existing Only update files that already exist --delete Delete files that don't exist on the sending side --delete-excluded also delete excluded files on the receiving side --delete-after Receiver deletes after transfer, not during --force Force deletion of directories even if not empty --ignore-errors Delete even if there are IO errors --max-delete=NUM Don't delete more than NUM files --log-format=FORMAT Log file transfers using specified format --partial Keep partially transferred files --progress Show progress during transfer -P equivalent to --partial --progress --stats Give some file transfer stats -T --temp-dir=DIR Create temporary files in directory DIR --compare-dest=DIR also compare destination files relative to DIR -u, --update update only (don't overwrite newer files) Misc Others: --address=ADDRESS bind to the specified address --blocking-io Use blocking IO for the remote shell --bwlimit=KBPS Limit I/O bandwidth, KBytes per second --config=FILE Specify alternate rsyncd.conf file --daemon Run as a rsync daemon --no-detach Do not detach from the parent --password-file=FILE Get password from FILE --port=PORT Specify alternate rsyncd port number -f, --read-batch=FILE Read batch file -F, --write-batch Write batch file --version Print version number -v, --verbose Increase verbosity -q, --quiet Decrease verbosity -4, --ipv4 Prefer IPv4 -6, --ipv6 Prefer IPv6 -h, --help show this help screen
TBC - Roderick
References
Good practical overview - http://jimmyg.org/blog/2007/rsync-basics.html
Review of the most common flags - http://www.evbackup.com/support-commonly-used-rsync-arguments/
GUI to learn and execute rsync - http://www.linuxjournal.com/content/rsync-its-grrrraphical
For MAC OS X consider - http://osxdaily.com/2009/02/19/command-line-back-ups-in-os-x/