Linux and Unix rsync command

Quick links

About rsync
Syntax
Examples
Related commands
Linux and Unix main page

About rsync

Faster, flexible replacement for rcp.

Syntax

rsync [OPTION]... SRC [SRC]... [USER@]HOST:DEST

rsync [OPTION]... [USER@]HOST:SRC DEST

rsync [OPTION]... SRC [SRC]... DEST

rsync [OPTION]... [USER@]HOST::SRC [DEST]

rsync [OPTION]... SRC [SRC]... [USER@]HOST::DEST

rsync [OPTION]... rsync://[USER@]HOST[:PORT]/SRC [DEST]

rsync [OPTION]... SRC [SRC]... rsync://[USER@]HOST[:PORT]/DEST

-v, --verboseincrease verbosity
-q, --quietsuppress non-error messages
-c, --checksumskip based on checksum, not mod-time & size
-a, --archivearchive mode; same as -rlptgoD (no -H)
-r, --recursiverecurse into directories
-R, --relativeuse relative path names
 
--no-relativeturn off --relative
--no-implied-dirsdon't send implied dirs with -R
-b, --backupmake backups (see --suffix & --backup-dir)
 
--backup-dir=DIRmake backups into hierarchy based in DIR
--suffix=SUFFIXbackup suffix (default ~ w/o --backup-dir)
-u, --updateskip files that are newer on the receiver
--inplaceupdate destination files in-place
-d, --dirstransfer directories without recursing
-l, --linkscopy symlinks as symlinks
-L, --copy-linkstransform symlink into referent file/dir
--copy-unsafe-linksonly "unsafe" symlinks are transformed
--safe-linksignore symlinks that point outside the tree
-H, --hard-linkspreserve hard links
-K, --keep-dirlinkstreat symlinked dir on receiver as dir
-p, --permspreserve permissions
-o, --ownerpreserve owner (root only)
-g, --grouppreserve group
-D, --devicespreserve devices (root only)
-t, --timespreserve times
-O, --omit-dir-timesomit directories when preserving times
-S, --sparsehandle sparse files efficiently
-n, --dry-runshow what would have been transferred
-W, --whole-file copy files whole (without rsync algorithm)
--no-whole-filealways use incremental rsync algorithm
-x, --one-file-systemdon't cross filesystem boundaries
-B, --block-size=SIZEforce a fixed checksum block-size
-e, --rsh=COMMANDspecify the remote shell to use
--rsync-path=PROGRAMspecify the rsync to run on remote machine
--existingonly update files that already exist
--ignore-existingignore files that already exist on receiver
--remove-sent-filessent files/symlinks are removed from sender
--delan alias for --delete-during
--deletedelete files that don't exist on sender
--delete-beforereceiver deletes before transfer (default)
--delete-duringreceiver deletes during xfer, not before
--delete-afterreceiver deletes after transfer, not before
--delete-excludedalso delete excluded files on receiver
--ignore-errorsdelete even if there are I/O errors
--forceforce deletion of dirs even if not empty
--max-delete=NUMdon't delete more than NUM files
--min-size=SIZEdon't transfer any file smaller than SIZE
--max-size=SIZEdon't transfer any file larger than SIZE
--partialkeep partially transferred files
--partial-dir=DIRput a partially transferred file into DIR
--delay-updatesput all updated files into place at end
--numeric-idsdon't map uid/gid values by user/group name
--timeout=TIMEset I/O timeout in seconds
-I, --ignore-timesdon't skip files that match size and time
--size-onlyskip files that match in size
--modify-window=NUMcompare mod-times with reduced accuracy
-T, --temp-dir=DIRcreate temporary files in directory DIR
-y, --fuzzyfind similar file for basis if no dest file
--compare-dest=DIRalso compare received files relative to DIR
--copy-dest=DIR... and include copies of unchanged files
--link-dest=DIRhardlink to files in DIR when unchanged
-z, --compresscompress file data during the transfer
-C, --cvs-excludeauto-ignore files in the same way CVS does
-f, --filter=RULEadd a file-filtering RULE
-Fsame as --filter='dir-merge /.rsync-filter'
repeated: --filter='- .rsync-filter'
--exclude=PATTERNexclude files matching PATTERN
--exclude-from=FILEread exclude patterns from FILE
--include=PATTERNdon't exclude files matching PATTERN
--include-from=FILEread include patterns from FILE
--files-from=FILEread list of source-file names from FILE
-0, --from0all *from file lists are delimited by nulls
--versionprint version number
--port=PORTspecify double-colon alternate port number
--blocking-iouse blocking I/O for the remote shell
--no-blocking-ioturn off blocking I/O when it is default
--statsgive some file-transfer stats
--progressshow progress during transfer
-P same as --partial --progress
-i, --itemize-changesoutput a change-summary for all updates
--log-format=FORMATlog file-transfers using specified format
--password-file=FILEread password from FILE
--list-onlylist the files instead of copying them
--bwlimit=KBPSlimit I/O bandwidth; KBytes per second
--write-batch=FILEwrite a batched update to FILE
--read-batch=FILEread a batched update from FILE
--protocol=NUMforce an older protocol version to be used
--checksum-seed=NUMset block/file checksum seed (advanced)
-4, --ipv4prefer IPv4
-6, --ipv6prefer IPv6
-h, --helpshow this help screen

Rsync can also be run as a daemon, in which case the following options are accepted:

--daemonrun as an rsync daemon
--address=ADDRESSbind to the specified address
--bwlimit=KBPSlimit I/O bandwidth; KBytes per second
--config=FILEspecify alternate rsyncd.conf file
--no-detachdo not detach from the parent
--port=PORTlisten on alternate port number
-v, --verboseincrease verbosity
-4, --ipv4prefer IPv4
-6, --ipv6prefer IPv6
-h, --helpshow this help screen

Examples

rsync -t *.htm hope:public_html/

The above example would use rsync to transfer all .htm files to the public_html directory on the hope computer.

Related commands

rcp