Skip to content

rsync Command Builder

Build an rsync command for Linux and macOS: archive, delete, exclude, SSH and backup options explained, trailing-slash and --delete safety checks.

rsync is the standard way to copy, sync and back up folders on Linux and macOS, locally or to another machine over SSH: it sends only what changed, keeps permissions and times, and can mirror, snapshot and resume. It also has well over a hundred options. Tick the ones you need and the command is built as you go, with each option explained and checks for the mistakes that cost data: a source without (or with) a trailing slash, --delete without a dry run, and excludes that don't match. Paste an existing command to see what it does. Option descriptions are based on the rsync project's manual page.

Local only

Built in your browser. Your paths and options are never sent to tclient.com.

This page runs on your device (WebAssembly), so server, share and host names stay there. A share link is only created when you click Copy link, and it keeps everything after # in the address, which browsers never send to a server.

Start from a preset

Command

rsync -avhP /srv/www/ /backup/www/
  • Info: The source ends with /, so the contents of /srv/www/ go straight into the destination.

Paste an existing command

rsync command or script line

Source and destination

Source (local path or user@host:path)
Destination (local path or user@host:path)
A trailing slash on the source matters: src/ copies what's inside src, src copies the folder itself. Paths are quoted for bash when needed.

Basics and output

4 selected

Archive mode, recursion, what rsync prints, and dry runs.

-a, --archive
Archive mode: recursive, keeping links, permissions, times, group, owner and devices.
-r, --recursive
Copies folders and everything in them.
-v, --verbose
Lists the files being transferred.
-h, --human-readable
Prints sizes and speeds as K, M, G.
--progress
Shows progress for each file.
-P
Shorthand for --partial --progress.
--info
Picks exactly which kinds of information rsync prints.
-i, --itemize-changes
Prints a change code for every file it updates.
--stats
Prints transfer statistics at the end.
-q, --quiet
Prints only errors.
-n, --dry-run
Shows what would happen without changing anything.

What to preserve

Which files to transfer

Deleting

Include and exclude

Transfer, network and backups

Command

rsync -avhP /srv/www/ /backup/www/
  • Info: The source ends with /, so the contents of /srv/www/ go straight into the destination.

Every rsync option

The options people use most, based on the rsync manual page (rsync --help lists them all). Open a section for the details.

Archive mode, recursion, what rsync prints, and dry runs.

OptionWhat it doesExample
--archive, -a
Archive mode: recursive, keeping links, permissions, times, group, owner and devices. The usual starting point for copies and backups: the same as -rlptgoD. It doesn't include hard links (-H), ACLs (-A) or extended attributes (-X); add those if you need them.
rsync -a /srv/www/ /backup/www/
Includes -r, -l, -p, -t, -g, -o, -D.
--recursive, -r
Copies folders and everything in them. Without -r (or -a), rsync copies only the files named on the command line and skips folders.
rsync -r src/ dest/
--verbose, -v
Lists the files being transferred. Prints each file as it's sent and a summary at the end. Repeat it (-vv) for more detail.
rsync -av src/ dest/
--human-readable, -h
Prints sizes and speeds as K, M, G. Makes the numbers in progress and summary output readable at a glance.
rsync -avh src/ dest/
--progress
Shows progress for each file. Prints a progress line for every file as it transfers: bytes, percentage, speed and time left.
rsync -a --progress big.iso server:/data/
-P
Shorthand for --partial --progress. Keeps partly transferred files so an interrupted copy can resume, and shows per-file progress. The common choice for big files over the network.
rsync -aP big.iso server:/data/
Includes --partial, --progress.
--info=FLAGS
Picks exactly which kinds of information rsync prints. Fine-grained output control. The popular one is progress2: a single progress line for the whole transfer instead of one per file. rsync --info=help lists every flag.
rsync -a --info=progress2 src/ dest/
--itemize-changes, -i
Prints a change code for every file it updates. Each line starts with an 11-character code saying what changed (content, size, times, permissions, a new file, a deletion). Combined with --dry-run it's the clearest preview of what a run will do.
rsync -ai --dry-run src/ dest/
--stats
Prints transfer statistics at the end. Number of files, how many were transferred, total and literal data sent, and the speedup from the delta algorithm.
rsync -a --stats src/ dest/
--quiet, -q
Prints only errors. Suppresses everything except error messages, for cron jobs whose output gets mailed.
rsync -aq src/ dest/
--dry-run, -n
Shows what would happen without changing anything. A trial run: rsync goes through the whole comparison but transfers, deletes and changes nothing. Add -v or -i to see the list. Do this before any run with --delete.
rsync -avn --delete src/ dest/

Permissions, owners, times, links, ACLs and how paths are recreated.

OptionWhat it doesExample
--perms, -p
Keeps permissions. Sets the destination's permission bits to match the source. Part of -a.
rsync -rp src/ dest/
--times, -t
Keeps modification times. Copies each file's modification time. Without it, the next run can't skip unchanged files by time. Part of -a.
rsync -rt src/ dest/
--group, -g
Keeps the group. Sets each file's group to match the source (by name, unless --numeric-ids). Part of -a.
rsync -rg src/ dest/
--owner, -o
Keeps the owner (only when run as root). Sets each file's owner to match the source. Only root can change owners, so as a normal user it has no effect. Part of -a.
sudo rsync -ao src/ dest/
-D
Keeps device and special files (--devices --specials). Recreates device files, named pipes and sockets. Devices need root. Part of -a.
sudo rsync -aD / /mnt/clone/
--acls, -A
Keeps ACLs (and permissions). Copies POSIX access control lists. Both systems need ACL support; implies --perms. Not part of -a.
rsync -aA /srv/share/ /backup/share/
--xattrs, -X
Keeps extended attributes. Copies extended attributes (SELinux labels, macOS metadata, capabilities). Not part of -a.
rsync -aX /srv/ /backup/srv/
--numeric-ids
Keeps owner and group by number, not by name. Normally rsync maps users and groups by name between the two systems. With this, the numeric IDs are copied as they are: what you want for full-system backups and restores.
rsync -aHAX --numeric-ids / backup:/srv/clone/
--chmod=CHMOD
Changes permissions on the way. Applies chmod-style changes to the copies, for example D755,F644 for folders 755 and files 644, or u+rwX.
rsync -a --chmod=D2775,F664 src/ dest/
--chown=USER:GROUP
Sets owner and group on the copies. Gives every copied file this owner and group (USER:GROUP, either part optional). Setting the owner needs root on the receiving side.
sudo rsync -a --chown=www-data:www-data src/ /var/www/
--sparse, -S
Keeps sparse files sparse. Writes runs of zeros as holes, so sparse files such as VM disks don't grow to full size.
rsync -aS vm.img /backup/
--one-file-system, -x
Doesn't cross into other mounted file systems. Stops at mount points, so copying / doesn't wander into /proc, /mnt or network mounts.
rsync -ax / /mnt/clone/
--relative, -R
Recreates the full source path at the destination. rsync -R /var/log/nginx/ /backup/ creates /backup/var/log/nginx. Put /./ in the source to choose where the kept part starts.
rsync -aR /var/./log/nginx/ /backup/
--mkpath
Creates missing folders in the destination path. Normally rsync creates at most the last folder of the destination. With this, it creates the whole path, like mkdir -p.
rsync -a --mkpath src/ /backup/2026/october/

How rsync decides a file has changed, and size limits.

OptionWhat it doesExample
--update, -u
Skips files that are newer at the destination. Leaves destination files alone when their modification time is newer than the source's, so changes made on the other side aren't overwritten.
rsync -au laptop/ server:/share/
--checksum, -c
Compares files by checksum instead of size and time. Reads every file on both sides to compare checksums. Catches changes that kept the same size and time, but is much slower on big trees.
rsync -ac src/ dest/
--size-only
Treats files of the same size as unchanged. Ignores modification times. Useful when times aren't reliable, for example after a copy that didn't keep them.
rsync -r --size-only src/ dest/
--ignore-times, -I
Transfers every file, even those that match in size and time. Doesn't skip anything; with the delta algorithm unchanged files still send little data.
rsync -aI src/ dest/
--ignore-existing
Never updates files that already exist at the destination. Adds new files only. Handy for resuming a large first copy or topping up an archive.
rsync -a --ignore-existing src/ dest/
--existing
Only updates files that already exist at the destination. Creates no new files; refreshes only what's already there.
rsync -a --existing src/ dest/
--modify-window=NUM
Allows times to differ by this many seconds. Two files whose times are this close count as equal. Use 1 (or 2) when one side is FAT or exFAT, which store times in 2-second steps.
rsync -a --modify-window=1 src/ /media/usb/
--max-size=SIZE
Skips files larger than this. Leaves out any file bigger than the size given (K, M, G suffixes, for example 500M).
rsync -a --max-size=100M src/ dest/
--min-size=SIZE
Skips files smaller than this. Leaves out any file smaller than the size given.
rsync -a --min-size=1K src/ dest/

Removing files from the destination that are gone from the source, or from the source after copying.

OptionWhat it doesExample
--delete
Deletes files at the destination that aren't in the source. Makes the destination an exact mirror. Only folders that are part of the transfer are cleaned, and it needs -r or -a.
rsync -a --delete src/ dest/
Note: Removes files at the destination that aren't in the source. With the wrong destination, or a source path that's off by one folder, it empties the destination. Run with --dry-run first.
--delete-before
Deletes before transferring. Does all deletions first, which frees space when the destination is nearly full, at the cost of an extra pass.
rsync -a --delete-before src/ dest/
Note: Removes files at the destination that aren't in the source. With the wrong destination, or a source path that's off by one folder, it empties the destination. Run with --dry-run first.
--delete-during
Deletes folder by folder during the transfer. rsync's default way of deleting when talking to rsync 3.0.0 or newer.
rsync -a --delete-during src/ dest/
Note: Removes files at the destination that aren't in the source. With the wrong destination, or a source path that's off by one folder, it empties the destination. Run with --dry-run first.
--delete-delay
Finds deletions during the transfer, deletes at the end. Nothing is deleted until the transfer has finished, which is safer if the run is interrupted.
rsync -a --delete-delay src/ dest/
Note: Removes files at the destination that aren't in the source. With the wrong destination, or a source path that's off by one folder, it empties the destination. Run with --dry-run first.
--delete-after
Deletes after the transfer. Like --delete-delay but with a separate pass after the transfer.
rsync -a --delete-after src/ dest/
Note: Removes files at the destination that aren't in the source. With the wrong destination, or a source path that's off by one folder, it empties the destination. Run with --dry-run first.
--delete-excluded
Also deletes excluded files from the destination. Files matching your exclude patterns are removed from the destination too, so excluding a folder later cleans it out of the backup.
rsync -a --delete --delete-excluded --exclude=cache/ src/ dest/
Note: Removes files at the destination that aren't in the source. With the wrong destination, or a source path that's off by one folder, it empties the destination. Run with --dry-run first.
--max-delete=NUM
Stops deleting after this many files. A safety net: if more deletions would be needed, rsync skips the rest and exits with code 25. Catches a wrong source path before it wipes a backup.
rsync -a --delete --max-delete=100 src/ dest/
--remove-source-files
Deletes source files after they're copied (a move). Each file that transferred successfully is removed from the source; folders are left in place. Only use it on files nothing else is writing to.
rsync -a --remove-source-files /incoming/ archive:/data/
Note: Removes each source file once it has been copied. A mistake in the destination leaves the files only there.

Patterns and lists of files to leave out or pick.

OptionWhat it doesExample
--exclude=PATTERN (repeatable)
Leaves out files and folders matching a pattern. Patterns use wildcards: *.tmp, cache/ (a trailing slash matches folders only), /build (anchored at the top of the transfer). Repeat it for several patterns; the first matching rule wins.
rsync -a --exclude='*.tmp' --exclude=node_modules/ src/ dest/
--include=PATTERN (repeatable)
Keeps files matching a pattern that a later exclude would drop. Rules are checked in order, so an include before an exclude makes an exception: --include='*.pdf' --exclude='*'.
rsync -a --include='*/' --include='*.pdf' --exclude='*' src/ dest/
--exclude-from=FILE
Reads exclude patterns from a file. One pattern per line; blank lines and lines starting with # or ; are ignored.
rsync -a --exclude-from=/etc/backup/excludes.txt / backup:/srv/clone/
--include-from=FILE
Reads include patterns from a file. Like --exclude-from, for include patterns.
rsync -a --include-from=keep.txt --exclude='*' src/ dest/
--files-from=FILE
Copies exactly the files listed in a file. Reads a list of paths (relative to the source folder) and transfers only those. Implies --relative.
rsync -a --files-from=changed.txt /srv/ backup:/srv/
--prune-empty-dirs, -m
Doesn't create folders that end up empty. Useful with include/exclude rules that leave whole folder chains without any files.
rsync -am --include='*/' --include='*.log' --exclude='*' src/ dest/

Compression, bandwidth, partial files, SSH, timeouts, backups and logging.

OptionWhat it doesExample
--compress, -z
Compresses data in transit. Saves bandwidth over slow links. Pointless for local copies and for data that's already compressed (video, archives).
rsync -az src/ server:/data/
--compress-level=NUM
Sets the compression level. Higher compresses more and uses more CPU. The valid range depends on the compression algorithm in use.
rsync -az --compress-level=9 src/ server:/data/
--bwlimit=RATE
Limits the transfer speed. Caps the rate (a plain number is KiB per second; suffixes like 5M work too), so a backup doesn't saturate the link. 0 means no limit.
rsync -a --bwlimit=5M src/ server:/data/
--partial
Keeps partly transferred files to resume later. Normally an interrupted file is deleted. With this, the part that arrived is kept and the next run continues from it.
rsync -a --partial big.iso server:/data/
--partial-dir=DIR
Keeps partly transferred files in a separate folder. Like --partial, but the partial files wait in this folder (relative to the destination) instead of sitting at the destination under their real names.
rsync -a --partial-dir=.rsync-partial src/ server:/data/
--inplace
Updates destination files directly instead of via a temporary copy. Saves disk space and keeps hard links to big files (VM disks, databases), but a file is inconsistent while it's being updated.
rsync -a --inplace vm.qcow2 /backup/
--append-verify
Appends to shorter destination files, then verifies the whole file. For files that only ever grow (logs): sends just the new end. The full-file checksum catches a mismatch and resends.
rsync -a --append-verify /var/log/app/ backup:/logs/app/
--whole-file, -W
Sends whole files instead of only the changed parts. Turns off the delta algorithm, which is faster when the network is faster than the disks (local copies, LAN).
rsync -aW /data/ /mnt/nas/data/
--timeout=SECONDS
Gives up when nothing has moved for this many seconds. Without it a stalled connection can hang a cron job forever.
rsync -a --timeout=300 src/ server:/data/
--rsh=COMMAND, -e COMMAND
Sets the remote shell command, usually ssh with options. Use it for a different SSH port, key or options: ssh -p 2222 -i ~/.ssh/backup_key.
rsync -a -e 'ssh -p 2222' src/ user@server:/data/
--rsync-path=PROGRAM
Sets the rsync command to run on the remote side. For an rsync that's not on the remote PATH, or to run it with sudo there: --rsync-path='sudo rsync'.
rsync -a --rsync-path='sudo rsync' src/ user@server:/etc/app/
--backup, -b
Keeps a backup of each file it replaces or deletes. Renames the old version (with a ~ suffix, or into --backup-dir) instead of losing it.
rsync -ab src/ dest/
--backup-dir=DIR
Puts those backups in this folder. Old versions go into a separate folder tree (relative to the destination unless absolute), for example one per day.
rsync -a --delete -b --backup-dir=/backup/changed/2026-10-28 src/ /backup/current/
--suffix=SUFFIX
Sets the backup file suffix. The default is ~ (or nothing when --backup-dir is used).
rsync -ab --suffix=.bak src/ dest/
--log-file=FILE
Writes a log of what was done to a file. Records each transferred and deleted file with a timestamp, separately from what's printed on screen.
rsync -a --log-file=/var/log/rsync-backup.log src/ dest/