Skip to content

Rsync – Reference

cpx May 26, 2026 4 min read RSYNC/873

Version: 3.x

Purpose: Fast, versatile file-copying tool — local and remote, incremental delta transfer

Key feature: Only transfers changed portions of files (delta-transfer algorithm)

Config: No config file — all behavior controlled via CLI flags


Syntax

rsync [OPTIONS] SOURCE... DEST
rsync [OPTIONS] SOURCE... [USER@]HOST:DEST         # push
rsync [OPTIONS] [USER@]HOST:SOURCE... DEST          # pull
rsync [OPTIONS] SOURCE... rsync://[USER@]HOST/MOD   # daemon push
rsync [OPTIONS] rsync://[USER@]HOST/MOD DEST         # daemon pull

Trailing slash rule:

  • rsync src/ dest/ — copies contents of src into dest
  • rsync src dest/ — copies the directory itself into dest (creates dest/src/)

Core Options

ShortLongDescription
-a--archiveArchive mode = -rlptgoD (recurse, links, perms, times, group, owner, devices)
-r--recursiveRecurse into directories
-v--verboseIncrease verbosity (stack: -vv, -vvv)
-q--quietSuppress non-error messages
-h--human-readableHuman-readable sizes
-n--dry-runShow what would be done without doing it
-i--itemize-changesOutput change summary per file
--list-onlyList files instead of transferring

Transfer Behavior

ShortLongDescription
-c--checksumSkip based on checksum, not mod-time & size
-u--updateSkip files newer on receiver
--inplaceUpdate files in-place (no temp file)
--appendAppend data to shorter files
-W--whole-fileDisable delta-transfer (copy whole files)
-b--backupMake backups of overwritten files
--backup-dir=DIRStore backups in DIR
--suffix=SUFFIXBackup suffix (default: ~)
--remove-source-filesDelete source files after transfer
--ignore-existingSkip files that exist on receiver
--max-size=SIZEDon’t transfer files larger than SIZE
--min-size=SIZEDon’t transfer files smaller than SIZE
--delay-updatesPut updated files into place at end
-m--prune-empty-dirsPrune empty directory chains
-R--relativeUse relative pathnames

Delete Options

LongDescription
--deleteDelete extraneous files from dest
--delete-beforeDelete on receiver before transfer
--delete-duringDelete during transfer (default)
--delete-afterDelete on receiver after transfer
--delete-excludedAlso delete excluded files on receiver
--forceForce deletion of non-empty directories
--max-delete=NUMDon’t delete more than NUM files

Safety tip: Always use -n --delete first to preview deletions.


Preservation Options

ShortLongDescription
-p--permsPreserve permissions (in -a)
-o--ownerPreserve owner (root only, in -a)
-g--groupPreserve group (in -a)
-t--timesPreserve modification times (in -a)
-U--atimesPreserve access times
-N--crtimesPreserve creation times
-l--linksCopy symlinks as symlinks (in -a)
-L--copy-linksTransform symlinks into referent file
-H--hard-linksPreserve hard links
-D--devices --specials (in -a)
-A--aclsPreserve ACLs (implies -p)
-X--xattrsPreserve extended attributes
--chmod=CHMODAffect file/dir permissions
-E--executabilityPreserve executability
-S--sparseEfficiently handle sparse files
--numeric-idsDon’t map uid/gid to names
--fake-superStore privileged attrs using xattrs

Filter & Exclude

ShortLongDescription
--exclude=PATTERNExclude matching files
--include=PATTERNInclude matching files
--exclude-from=FILERead excludes from FILE
--include-from=FILERead includes from FILE
-f--filter=RULEAdd a filter rule
-C--cvs-excludeAuto-ignore CVS-style files
--files-from=FILERead source file list from FILE
-0--from0Null-terminated input

Pattern Syntax

PatternMatches
*.logAny file ending in .log
/foofoo in the transfer root only
foo/Only directories named foo
foo/**Everything inside foo/
**/barAny bar at any depth

Filter Rule Prefixes

PrefixMeaning
Exclude
Include
.Merge file
:Dir-merge file (per-directory rules)
HHide (sending side)
PProtect (from deletion on receiver)

Compression

ShortLongDescription
-z--compressCompress during transfer
--compress-level=NUMLevel 0–9
--compress-choice=STRzlib · lz4 · zstd · none
--skip-compress=LISTSkip for listed suffixes

Network & Remote Shell

ShortLongDescription
-e--rsh=COMMANDSpecify remote shell (default: ssh)
--rsync-path=PROGRAMPath to rsync on remote
--port=PORTSpecify port
--bwlimit=RATELimit bandwidth (K, M, G suffixes)
--timeout=SECONDSI/O timeout
--contimeout=SECONDSConnection timeout

Progress & Performance

ShortLongDescription
-P--partial --progress
--partialKeep partially transferred files
--partial-dir=DIRPut partials in DIR
--progressShow per-file progress
--info=progress2Single total progress bar
--statsPrint transfer statistics
-T--temp-dir=DIRCreate temp files in DIR

Itemize Output (-i)

11-character string: YXcstpoguax

PosCharMeaning
0Y< sent · > received · c local change · . not updated
1Xf file · d dir · L symlink · D device
2cChecksum differs
3sSize differs
4tMtime differs
5pPermissions differ
6oOwner differs
7gGroup differs
9aACL differs
10xXattr differs

. = no change, + = newly created.


Daemon Mode

rsync --daemon --config=/etc/rsyncd.conf

rsyncd.conf Key Options

[module_name]
    path = /data/share
    read only = yes
    auth users = user1, user2
    secrets file = /etc/rsyncd.secrets
    hosts allow = 192.168.1.0/24
    hosts deny = *
    max connections = 10
    use chroot = yes
    fake super = yes
    transfer logging = yes
    log file = /var/log/rsyncd.log
    refuse options = delete

Common Recipes

# Basic copy (archive + verbose + progress)
rsync -avhP src/ dest/

# Mirror with delete (exact copy)
rsync -avh --delete src/ dest/

# Dry run first (always!)
rsync -avhn --delete src/ dest/

# Remote backup over SSH
rsync -avhP --delete -e 'ssh -p 22' /data/ user@backup:/data/

# Custom SSH key
rsync -avhP -e 'ssh -i ~/.ssh/mykey' src/ user@host:dest/

# Bandwidth-limited transfer
rsync -avhP --bwlimit=50M src/ user@remote:dest/

# Resume interrupted transfer
rsync -avhP --partial src/ dest/

# Exclude patterns
rsync -avh --exclude='*.log' --exclude='.cache/' --exclude='node_modules/' src/ dest/

# Include only certain files
rsync -avh --include='*.jpg' --include='*/' --exclude='*' src/ dest/

# Preserve everything (ACLs, xattrs, hard links, sparse)
rsync -avhHAXS --numeric-ids src/ dest/

# Full system backup (as root)
rsync -avhHAXS --numeric-ids --delete \\
  --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*"} \\
  / /mnt/backup/

# Sync to NAS
rsync -avhP --delete -e 'ssh -i ~/.ssh/nas_key' \\
  /home/user/data/ nas:/volume1/backup/data/

# Show total progress (single progress bar)
rsync -avh --info=progress2 src/ dest/

# Verify existing copy with checksums
rsync -avhcn src/ dest/

# Speed up on LAN (skip compression, whole files)
rsync -avhW --no-compress src/ dest/

# Cron job (quiet, log to file)
rsync -ah --delete --log-file=/var/log/rsync-backup.log src/ dest/

rsync vs. Alternatives

FeaturersyncRobocopyrcloneFreeFileSync
Delta transferYesNoPartialNo
Remote (SSH)YesNo (SMB)Yes (cloud)No
Cloud storageNoNoYesYes
Preserve Unix permsYesN/APartialNo
Bandwidth limitYesYesYesNo
ResumableYes (-P)Yes (/Z)YesYes
PlatformLinux/macOS/WSLWindowsCross-platformCross-platform

Exit Codes

CodeMeaning
0Success
1Syntax/usage error
2Protocol incompatibility
3Errors selecting files
10Socket I/O error
11File I/O error
12Protocol data stream error
20Received SIGUSR1/SIGINT
23Partial transfer due to error
24Partial transfer — vanished source files
25--max-delete limit reached
30Timeout

Source: man rsync(1) · man rsyncd.conf(5) · rsync.samba.org

0 0 votes
Article Rating
guest

0 Comments
Oldest
Newest Most Voted
0
Would love your thoughts, please comment.x
()
x