rsync — quick reference
Core transfer modes
| When to use | Command |
|---|---|
Archive sync — permissions, times, symlinks, recursion (-rlptgoD) |
rsync -a /tmp/src/ /tmp/dst/ |
| Verbose file list during transfer | rsync -av /tmp/src/ /tmp/dst/ |
| Human-readable numbers in summary | rsync -avh /tmp/src/ /tmp/dst/ |
| Compress data during transfer | rsync -avz /tmp/src/ /tmp/dst/ |
| Preview changes without writing | rsync -avn /tmp/src/ /tmp/dst/ |
Same as --dry-run |
rsync -av --dry-run /tmp/src/ /tmp/dst/ |
| Show what changed (itemized) | rsync -avi /tmp/src/ /tmp/dst/ |
Recurse into directories (part of -a) |
rsync -r /tmp/src/ /tmp/dst/ |
| Copy directory entries only, no recursion | rsync -d /tmp/src/ /tmp/dst/ |
| Use delta algorithm (default); force whole-file copy | rsync -W /tmp/src/ /tmp/dst/ |
Deletion and mirroring
| When to use | Command |
|---|---|
| Delete files on destination that are absent from source | rsync -a --delete /tmp/src/ /tmp/dst/ |
| Delete during transfer (default delete mode) | rsync -a --delete-during /tmp/src/ /tmp/dst/ |
| Delete on destination before transfer starts | rsync -a --delete-before /tmp/src/ /tmp/dst/ |
| Delete on destination after transfer completes | rsync -a --delete-after /tmp/src/ /tmp/dst/ |
| Also delete excluded files from destination | rsync -a --delete-excluded /tmp/src/ /tmp/dst/ |
Cap how many files --delete may remove |
rsync -a --delete --max-delete=100 /tmp/src/ /tmp/dst/ |
| Remove source files after successful copy | rsync -a --remove-source-files /tmp/src/ /tmp/dst/ |
Remote shell and paths
| When to use | Command |
|---|---|
| Remote sync over SSH (trailing slash on source matters) | rsync -avz -e ssh /tmp/src/ user@host:/tmp/dst/ |
| Custom SSH port | rsync -avz -e "ssh -p 2222" /tmp/src/ user@host:/tmp/dst/ |
| Remote program path on server | rsync -av --rsync-path=/usr/bin/rsync /tmp/src/ user@host:/tmp/dst/ |
List module contents on rsync daemon (::) |
rsync rsync://host/module/ |
| Daemon URL form | rsync -av /tmp/src/ rsync://host/module/path/ |
Preservation and metadata
| When to use | Command |
|---|---|
Preserve permissions (in -a) |
rsync -p /tmp/src/ /tmp/dst/ |
Preserve modification times (in -a) |
rsync -t /tmp/src/ /tmp/dst/ |
Preserve symlinks as symlinks (in -a) |
rsync -l /tmp/src/ /tmp/dst/ |
| Copy symlink target instead of link | rsync -L /tmp/src/ /tmp/dst/ |
| Preserve hard links | rsync -aH /tmp/src/ /tmp/dst/ |
| Preserve ACLs | rsync -aA /tmp/src/ /tmp/dst/ |
| Preserve extended attributes | rsync -aX /tmp/src/ /tmp/dst/ |
| Preserve owner (superuser) | rsync -ao /tmp/src/ /tmp/dst/ |
| Preserve group | rsync -ag /tmp/src/ /tmp/dst/ |
| Preserve device and special files | rsync -aD /tmp/src/ /tmp/dst/ |
Filters, limits, and updates
| When to use | Command |
|---|---|
| Skip files matching a pattern | rsync -av --exclude='*.tmp' /tmp/src/ /tmp/dst/ |
| Read exclude patterns from a file | rsync -av --exclude-from=/tmp/exclude.txt /tmp/src/ /tmp/dst/ |
| Force include after exclude rules | rsync -av --include='*.txt' --exclude='*' /tmp/src/ /tmp/dst/ |
| Skip files newer on receiver | rsync -avu /tmp/src/ /tmp/dst/ |
| Skip updating files that already exist on receiver | rsync -av --ignore-existing /tmp/src/ /tmp/dst/ |
| Only update files that already exist on receiver | rsync -av --existing /tmp/src/ /tmp/dst/ |
| Skip based on checksum instead of time/size | rsync -ac /tmp/src/ /tmp/dst/ |
| Do not cross filesystem boundaries | rsync -ax /tmp/src/ /tmp/dst/ |
| Max file size to transfer | rsync -av --max-size=1M /tmp/src/ /tmp/dst/ |
| Min file size to transfer | rsync -av --min-size=1k /tmp/src/ /tmp/dst/ |
| Bandwidth limit (KB/s) | rsync -av --bwlimit=1000 /tmp/src/ /tmp/dst/ |
Partial transfers, backups, and listing
| When to use | Command |
|---|---|
| Keep partial files after interruption | rsync -av --partial /tmp/src/ /tmp/dst/ |
| Partial files in a dedicated directory | rsync -av --partial-dir=.rsync-partial /tmp/src/ /tmp/dst/ |
| Progress per file | rsync -av --progress /tmp/src/ /tmp/dst/ |
Partial plus progress (-P) |
rsync -avP /tmp/src/ /tmp/dst/ |
| Make backups of replaced files | rsync -avb /tmp/src/ /tmp/dst/ |
| Backups into a dated directory | rsync -avb --backup-dir=/tmp/backup /tmp/src/ /tmp/dst/ |
| List files in source without copying | rsync --list-only /tmp/src/ |
| Transfer statistics summary | rsync -av --stats /tmp/src/ /tmp/dst/ |
Safety, encoding, and help
| When to use | Command |
|---|---|
| Create missing destination path components | rsync -av --mkpath /tmp/new/nested/dst/ /tmp/final/ |
| Ignore missing source args (scripting) | rsync -av --ignore-missing-args /tmp/src/ /tmp/dst/ |
| Quiet mode — errors only | rsync -aq /tmp/src/ /tmp/dst/ |
| IPv4 only | rsync -av -4 user@host:/tmp/src/ /tmp/dst/ |
| IPv6 only | rsync -av -6 user@host:/tmp/src/ /tmp/dst/ |
| Show help | rsync --help |
| Show version and features | rsync --version |
rsync — command syntax
Synopsis from rsync --help on Ubuntu 25.04 (rsync 3.4.1):
rsync [OPTION]... SRC [SRC]... DEST
or rsync [OPTION]... SRC [SRC]... [USER@]HOST:DEST
or rsync [OPTION]... [USER@]HOST:SRC [DEST]A trailing slash on SRC/ copies the directory contents; without it, rsync creates a subdirectory named after SRC under DEST. Remote paths use user@host:path with SSH when combined with -e ssh (default remote shell on most systems).
rsync — command examples
Essential Local archive sync with -av
Archive mode is the usual starting point for backups — it preserves permissions, timestamps, symlinks, and recursion in one flag.
Prepare a small tree and sync it:
rm -rf /tmp/rsync-src /tmp/rsync-dst
mkdir -p /tmp/rsync-src/sub
echo "hello world" > /tmp/rsync-src/file1.txt
echo "nested" > /tmp/rsync-src/sub/file2.txt
rsync -av /tmp/rsync-src/ /tmp/rsync-dst/Sample output:
sending incremental file list
file1.txt
sub/
sub/file2.txt
sent 248 bytes received 62 bytes 620.00 bytes/sec
total size is 19 speedup is 0.06Confirm the mirror:
The step below orders lines with sort; see the sort command for flags, key fields, and piping from awk, find, or ls.
find /tmp/rsync-dst -type f | sortSample output:
/tmp/rsync-dst/file1.txt
/tmp/rsync-dst/sub/file2.txtThe trailing slash on /tmp/rsync-src/ copies contents into /tmp/rsync-dst/ instead of creating /tmp/rsync-dst/rsync-src/.
Essential Preview a mirror with --dry-run and --delete
Before mirroring production data, run a dry run — output matches a real run but no files are created, changed, or deleted.
Add a file only on the destination, then preview:
echo "orphan" > /tmp/rsync-dst/old.txt
rsync -avn --delete /tmp/rsync-src/ /tmp/rsync-dst/Sample output:
sending incremental file list
deleting old.txt
./
sent 132 bytes received 13 bytes 290.00 bytes/sec
total size is 19 speedup is 0.13 (DRY RUN)(DRY RUN) confirms nothing was removed yet. Drop -n when the preview looks correct.
Common Compressed transfer with -avz
Compression helps over slow or metered links; on fast localhost copies the benefit is small but the flag is harmless for text-heavy trees.
Run the command:
rsync -avz /tmp/rsync-src/file1.txt /tmp/rsync-dst/Sample output:
sending incremental file list
sent 59 bytes received 12 bytes 142.00 bytes/sec
total size is 12 speedup is 0.17When files are already identical, rsync sends almost no payload — the summary line is still useful to confirm both sides match.
Common See exactly what changed with --itemize-changes
Itemized output is the fastest way to learn why rsync touched a file — each leading column is a change code.
Run the command:
echo "updated" >> /tmp/rsync-src/file1.txt
rsync -avi /tmp/rsync-src/ /tmp/rsync-dst/Sample output:
sending incremental file list
>f.st...... file1.txt
sent 207 bytes received 39 bytes 492.00 bytes/sec
total size is 24 speedup is 0.10>f means a regular file was updated; .st indicates size and time differed. See man rsync for the full legend.
Common Exclude patterns during sync
Exclude rules are common in log and build-tree mirrors when you must not copy transient files.
Run the command:
rsync -avn --exclude='*.txt' /tmp/rsync-src/ /tmp/rsync-dst/Sample output:
sending incremental file list
sent 82 bytes received 13 bytes 190.00 bytes/sec
total size is 0 speedup is 0.00 (DRY RUN)No .txt files appear in the file list — only directories would transfer. Combine with --exclude-from for long lists.
Common Mirror deletions with --delete
Backup jobs that should match the source exactly need --delete so orphaned files on the destination are removed.
Remove a source file and sync:
rm /tmp/rsync-src/sub/file2.txt
rsync -av --delete /tmp/rsync-src/ /tmp/rsync-dst/
ls -R /tmp/rsync-dst/Sample output:
sending incremental file list
deleting sub/file2.txt
sub/
sent 132 bytes received 13 bytes 290.00 bytes/sec
total size is 19 speedup is 0.13
/tmp/rsync-dst/:
file1.txt
sub/tmp/rsync-dst/sub/ remains but file2.txt is gone — destination now mirrors source.
Common List directory contents without copying
--list-only behaves like a remote-aware ls — useful to verify paths before a large transfer.
Run the command:
rsync --list-only /tmp/rsync-src/Sample output:
drwxr-xr-x 100 2026/07/01 14:40:48 .
-rw-r--r-- 5 2026/07/01 14:40:48 a.txt
-rw-r--r-- 12 2026/07/01 14:40:04 file1.txt
drwxr-xr-x 60 2026/07/01 14:40:04 subColumn layout matches rsync's machine-readable listing format — see rsync --help for field meanings.
Advanced Remote sync over SSH with -e ssh
The -e ssh form is the usual replacement for scp when you need incremental sync, excludes, or --delete.
Syntax (run from a host that has SSH access to the remote):
Rsync over SSH uses -e ssh for encrypted transfers; the ssh command covers remote login forms (user@host) rsync relies on.
rsync -avz -e ssh /tmp/rsync-src/ user@remote-host:/tmp/rsync-dst/On first connect, SSH may prompt to verify the host key — that is expected. For automation, configure keys in ~/.ssh and optionally StrictHostKeyChecking policy in ssh_config.
rsync does not copy between two remote hosts in one command — the process must run on one endpoint with access to the other.
rsync — when to use / when not
| Use rsync when | Use something else when |
|---|---|
|
|
rsync vs scp
| rsync | scp | |
|---|---|---|
| Algorithm | Delta — sends changed blocks | Full file copy each run |
| Mirroring | --delete, excludes, dry run |
No built-in mirror semantics |
| Resume | --partial, --append |
No standard resume |
| Simplicity | More flags | Single command, fewer options |
| Best for | Repeated backups and large trees | Quick one-off copies |
See the scp command for passwordless SSH copy examples.
Related commands
File transfer and backup workflow on Linux.
| Command | One line |
|---|---|
| rsync | Incremental sync and mirroring (this page) |
| tar | Archive trees before offline copy |
Browse the full index in our Linux commands reference.
rsync — interview corner
What is rsync used for?
rsync synchronizes files and directories locally or over the network. After the first copy, it sends only differences (the delta algorithm), which makes repeated backups faster than copying whole files every time.
Archive mode -a is shorthand for -rlptgoD — recursion, symlinks, permissions, times, group, owner (when root), and devices.
A strong answer is:
"rsync efficiently syncs file trees — delta transfers after the first run, -a for permissions and times, --delete for true mirroring, and -e ssh for remote hosts."
Why does the trailing slash on the source path matter?
rsync /tmp/src/ (with slash) copies the contents of src into the destination.
rsync /tmp/src (no slash) copies the directory itself, creating /dest/src/.
Getting this wrong is a common backup mistake.
A strong answer is:
"Trailing slash on the source means copy contents into the destination; without it, rsync creates a subdirectory named after the source."
When is rsync better than scp?
Use rsync when you run the same job repeatedly (nightly backups), need --delete mirroring, --exclude, --dry-run, or --partial resume.
Use scp for a quick, one-time copy where you do not need sync semantics.
A strong answer is:
"rsync for incremental sync, mirroring, excludes, and dry runs; scp for simple one-off copies."
How do you preview an rsync job safely?
Add -n or --dry-run. rsync prints the same file list and delete lines but does not modify the destination.
Pair with -v and --itemize-changes when you need detail.
A strong answer is:
"I always run rsync -avn --delete first — the (DRY RUN) marker confirms nothing was written."
What does rsync --delete do?
--delete removes files on the destination that are not present on the source — turning a copy into a mirror.
Use dry run first. Combine with --max-delete if you need a safety cap.
A strong answer is:
"--delete makes the destination match the source by removing extra files — I preview with -n and use --max-delete on critical paths."
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
Permission denied preserving owner |
Not root on one side | Run with sudo or drop -o / use --no-owner |
No such file or directory on destination |
Missing parent path | Add --mkpath (rsync 3.4+) or mkdir -p first |
SSH Host key verification failed |
Unknown host key | Connect with ssh once or set StrictHostKeyChecking in SSH config |
| Everything transfers every run | Clock skew or -I/--ignore-times |
Fix time sync; avoid --ignore-times unless intended |
rsync: command not found on remote |
rsync not installed on remote | Install rsync on both ends or set --rsync-path |
| Dest has extra nested directory | Missing trailing slash on source | Use src/ form |
