rsync Flag Explainer

Paste any rsync command and get a per-flag breakdown of what it does.

Client-side only — nothing leaves your browser

rsync -avzP --delete --exclude=node_modules /src/ user@host:/dst/
command flag path value

Source

/src/

Destination

user@host:/dst/

This command contains destructive flags: --delete

Always test with --dry-run (-n) first. A wrong source or trailing slash can wipe files on the destination.

6 known
FlagLong FormMeaning
-a
--archiveArchive mode — equivalent to -rlptgoD. Recursively copies files while preserving symlinks, permissions, modification times, group, owner, and device/special files.
-v
--verboseVerbose output. Use -vv or -vvv for increasing detail. Shows files as they are transferred.
-z
--compressCompress file data during transfer. Useful over slow networks; usually unnecessary on fast LANs or when files are already compressed.
-P
Shortcut for --partial --progress. Keeps partially transferred files on interrupt and shows a per-file progress bar.
--deleteRisky
Delete files on the destination that no longer exist on the source. Makes the destination an exact mirror — files removed from the source are erased on the destination.
--exclude
Exclude files matching the given pattern (e.g. --exclude=node_modules or --exclude='*.log'). Can be specified multiple times.

What does the rsync command do?

rsync ("remote sync") is a Unix utility that efficiently transfers and synchronizes files between two locations — locally, between two machines, or to and from a remote server over SSH. Its claim to fame is the delta-transfer algorithm: rsync only sends the parts of a file that have changed, which makes incremental backups and large-tree mirroring dramatically faster than tools like scp or cp. The catch is that rsync's behavior is controlled almost entirely by its flags, and a single missing or misplaced flag can mean copying the wrong files, blowing away the wrong directory, or silently dropping permissions.

Most Common rsync Flag Combinations

Most real-world rsync commands you will see in scripts, tutorials, and Stack Overflow answers fall into a handful of patterns:

CombinationWhat it does
-aArchive — recursive + preserve everything (perms, times, owner, group, symlinks, devices).
-avArchive with verbose output. Most common starting point.
-avzArchive, verbose, compress in transit. Standard for SSH transfers over the internet.
-avzPAdds --partial --progress for resumable transfers with a progress bar.
-avhArchive, verbose, human-readable file sizes.
-avnArchive verbose dry-run — see what would happen without doing it.
-av --deleteMirror mode — destination becomes an exact copy of source, including deletions.

Risky rsync Flags to Watch For

These flags can permanently delete data. Always pair them with --dry-run (-n) the first time you run a command:

FlagRisk
--deleteErases anything on the destination that isn't in the source. A wrong source path can empty an entire directory.
--delete-excludedAlso deletes files that match your --exclude patterns from the destination.
--remove-source-filesDeletes files from the source after a successful transfer — turns rsync into a move.
--inplaceOverwrites files in-place rather than via a temp file. If the transfer fails partway, the destination file is left corrupted.

Frequently Asked Questions

What are rsync flags?
Flags (also called options or switches) are the letters and words after the rsync command that change its behavior — for example -a tells rsync to use archive mode and --delete tells it to remove destination files that aren't in the source. rsync supports both short flags (a single dash and one letter, like -v) and long flags (two dashes and a word, like --verbose). Short flags can be combined: -avz is the same as -a -v -z. Most rsync commands you'll encounter are mostly flags — they control recursion, what to preserve, what to delete, what to compress, and how to talk to the remote host.
What does -avz mean in rsync?
-avz is the most common rsync flag combination, especially for transfers over SSH. It expands to three separate flags: -a (archive mode — recursive copy that preserves permissions, modification times, owners, groups, symlinks, and devices), -v (verbose — print each file as it's transferred), and -z (compress data during transit, useful over slower networks). You'll often see it written as -avzP, which adds --partial --progress so transfers are resumable and show a live progress bar.
What is the difference between rsync --include and --exclude?
--exclude tells rsync to skip files matching a pattern; --include tells it to keep files that would otherwise be excluded. Order matters: rsync evaluates rules top to bottom and uses the first match wins. To copy only .txt files from a directory, the trick is --include='*.txt' --include='*/' --exclude='*' — include the files you want, include directories so rsync can recurse into them, then exclude everything else. Putting --exclude='*' before your --include rules will silently match everything first and skip your target files.
Should I use the -z (--compress) flag with rsync?
Use -z when transferring over a slow or metered network (typically over the internet via SSH) and the files you're sending are compressible — text, source code, logs. Skip -z on a fast LAN or local disk-to-disk copies; the CPU overhead of compression actually slows the transfer down because the network isn't the bottleneck. Skip it for already-compressed content too (videos, JPEGs, .zip, .gz, Docker images) — you'll just burn CPU rewriting incompressible bytes. A modern alternative is --compress-choice=zstd for better speed-vs-ratio on rsync 3.2+.
Why does the trailing slash matter in rsync?
A trailing slash on the source path changes what rsync copies. rsync /src/ /dst/ copies the contents of /src into /dst — you end up with /dst/file1, /dst/file2. rsync /src /dst/ (no trailing slash on source) copies the directory itself into /dst — you end up with /dst/src/file1, /dst/src/file2. The trailing slash on the destination is cosmetic and doesn't change behavior. This is the single most common rsync footgun, especially when combined with --delete: a misplaced slash can dump files in the wrong place or wipe an entire directory.

Related Tools

Need to manage SSH connections?

SSH Workbench lets you connect, browse files, and manage servers visually.

Try SSH Workbench Free