Rsync Command Builder
Pick the sync you mean and get the rsync command — the -a flags spelled out, the dangerous ones marked, and a dry run offered first.
rsync \ -avzn \ --delete \ --exclude='*.log' \ --exclude='/node_modules/' \ -e 'ssh -p 2222' \ /srv/site/ \ backup@nas:/vol/site
8 parts
The command this form describes, quoted for POSIX sh, bash and zsh. Nothing runs here — a browser cannot reach your files or open a connection.
This command deletes files
Files on the destination that the source no longer has are removed — no prompt, no trash can. Excluded files are kept unless --delete-excluded is on.
This command is already a dry run (-n): it reports what would be deleted and touches nothing.
Code W_DELETE_DESTRUCTIVE--delete removes files from the destination — no prompt, no trash can. Anything there that the source no longer has is gone.Code W_EXCLUDED_FILES_PROTECTED--delete keeps excluded files on the receiver (proven here: an excluded *.log survived a real --delete). Add --delete-excluded only if you want them removed too.Code N_TRAILING_SLASH_MEANINGsource/ copies the CONTENTS of the directory; source without the slash copies the directory itself into the destination — the executed before/after pair is printed below.Code N_OWNER_NEEDS_ROOT-a preserves owner and group (-o, -g), which the RECEIVING side honours only when it runs as root — as a normal user the files land owned by you.
One entry per emitted part, in command order. Each line is this page's own summary and links to the manual it was checked against.
rsyncSynchronizes the destination with the source, sending only what differs. manual-aArchive mode — exactly -rlptgoD (recursion plus permissions, times, group, owner, devices). It does NOT include -H, ACLs or xattrs. manual-vVerbose: name each file as it is considered. manual-zCompress file data in transit. Pays on a slow link; pure cost on a local copy or already-compressed data. manual-nDry run: report what would change without changing it. Always the first run for anything carrying --delete. manual--deleteRemove files from the destination that no longer exist in the source. Excluded files are kept unless --delete-excluded is added. manual--excludeSkip paths matching the pattern. A leading / anchors it to the transfer root, a trailing / matches directories only. manual-eThe transport program, as ONE quoted word — 'ssh -p 2222' rides intact. Ignored on a local-to-local copy. manualsourceWhat to copy. A trailing / means the CONTENTS of the directory; without it the directory itself lands inside the destination. manualdestinationWhere it goes — a local path, or host:path / user@host:path over the remote shell. manual
-a decomposed
What archive mode actually switches on — and it does NOT include -H, ACLs or xattrs on this host (the -A and -X refusals are in the golden pack).
| Flag | Meaning |
|---|---|
-r | Recurse into directories. |
-l | Copy symlinks as symlinks, not the files they point at. |
-p | Preserve permissions. |
-t | Preserve modification times — what lets the next run skip unchanged files. |
-g | Preserve the group. Setting an arbitrary group needs root on the receiver. |
-o | Preserve the owner — honoured only when the receiving side runs as root. |
-D | Preserve device and special files (needs root to recreate them). |
Nothing runs here: this page writes the command, your terminal runs it.
Press ? for shortcuts
Do it offline:$ rsync --version
How to use it
- Enter the source and destination, and decide whether the source keeps its trailing slash — with it rsync copies the contents, without it the directory itself lands inside the destination.
- Tick the flags you need, or load a recipe. Archive mode can be spelled out as -rlptgoD, and the pane rewrites live as you change anything.
- Pick a delete mode only when the destination should lose files. The warning card shows the same command with -n added: run that first and read the deleting lines it prints.
- Copy the command or download it as .sh. Up to 64 exclude patterns and 4,096 characters per value are accepted; over that the builder refuses instead of truncating.
Pick the sync you mean — mirror, backup, over SSH — and read the rsync command off the pane, each flag explained beside it. Every one of the rsync examples here was executed against this page's golden host, Apple's bundled openrsync (protocol 29, "rsync version 2.6.9 compatible"), not Samba rsync 3.x: flags only 3.x accepts are labelled and cited, and the dangerous ones arrive marked, with a rehearsal offered first.
Examples
Mirror rehearsal · -n before --deletersync -avn --delete src/ dst/Executed on the golden host: the dry run listed a deleting line for the one file only the destination had, and that file was proven still on disk afterwards. Drop the n once the list reads right.
Copy without the noise · --excludersync -avz --exclude='*.log' src/ dst/Executed for real: every non-log file landed, all three .log files stayed behind. The pattern is emitted in single quotes — bare, the shell would expand *.log against your current directory first.
Snapshot backup · --link-destrsync -av --link-dest=/backups/2026-08-17 /srv/site/ /backups/2026-08-18/Unchanged files become hard links into yesterday's snapshot instead of copies, so each day costs only what changed. Keep the base absolute: a relative one resolves against the destination, and this host creates the links even under -n.
Over SSH · a path with a spacersync -az -e 'ssh -p 2222' '/Volumes/Media Vault/site/' backup@nas:/vol/siteTwo quoting rules in one line: the -e program rides as one word, and the space in Media Vault stays inside its quotes. The remote side is untouched here — nothing on this page opens a connection.
rsync 3.x only · --info=progress2rsync -av --info=progress2 src/ dst/This card is labelled rsync 3.x and cited, because the golden host refuses the flag verbatim: rsync: unrecognized option `--info=progress2'. So too --mkpath — rsync: unrecognized option `--mkpath' — which is why the version check below comes first.
Every example on this page is executed against the same engine that powers the tool, on every build.
Gotchas worth knowing
One character decides what gets copied
src/ means the contents of src; src means the directory itself, nested into the destination. Both forms were executed here and the two transfer lists differ exactly by that src/ prefix. Under a delete mode the slash decides what counts as extra, so the risky pairing draws a warning.
-a is seven flags, and three things it is not
Archive mode expands to -rlptgoD — recursion, symlinks, permissions, times, group, owner, devices — and the expanded spelling produced a byte-identical transfer list when executed. It does not preserve hard links (-H is separate), -A and -X do not exist on this host at all, and owner and group stick only when the receiver runs as root.
--delete respects excludes until told otherwise
In a real run against a fixture tree, --delete removed the stale file but left the excluded *.log on the receiver untouched; adding --delete-excluded then removed it. That pair of executions is the whole story: excludes protect files from deletion, and --delete-excluded is the explicit opt-out.
What this page will not do
It never transfers anything and never opens a connection — the command is text until your terminal runs it. Daemon mode (rsync:// and rsyncd.conf), scp, sftp and rclone, PowerShell and cmd.exe quoting, and schedule authoring are out of scope, and SSH keys belong to the key generator page. No flag is claimed for a version this page did not execute or cite.
Common errors
The source path is empty — rsync needs something to copy. A directory with a trailing / means its contents.- The builder refuses to guess a path; the destination has its own twin refusal.
--info=progress2 is rsync 3.x only. This page's host refused it verbatim: rsync: unrecognized option `--info=progress2' — switch the dialect to rsync 3.x (cited) or drop the flag.- The most common recipe ingredient that silently assumes Samba rsync 3.x; the refusal is the host's own line.
"F644" is an octal mode — rsync 3.x takes those, but this page's host does not (its verbatim refusal: rsync: --chmod=F644: invalid argument). Write the symbolic form instead, like ug=rwX or D2775's symbolic equivalent.- Octal --chmod values are an rsync 3.x habit; symbolic ones were executed here and work on both.
"fast" is not a bandwidth limit this host accepts (the live refusal reads: rsync: bad bwlimit: Invalid argument). Use a number of KiB/s like 100, a decimal like 1.5, or a suffixed form like 100K or 2g — all executed here.- Every accepted shape in that list was run against the golden host before being promised.
The source path is 4097 characters — this builder accepts up to 4096 per value. Shorten it; nothing is truncated for you.- Both numbers are printed straight off the enforcing constant — the refusal and the limit cannot disagree.
The source path contains a control character (U+0000) at position 2 — a shell argument cannot carry it. Remove it, or retype the path: a�b- Usually a paste that brought an invisible byte along; spaces, tabs and even newlines are fine — they ride inside the quotes.
FAQ
Why does the page keep saying openrsync instead of just rsync?
Because that is what actually ran here. macOS ships Apple's build of openrsync, which answers rsync --version with protocol 29 and "rsync version 2.6.9 compatible", and it refuses several flags Samba rsync 3.x accepts. Saying rsync flatly would smuggle in claims this page cannot back.
Does this page ever run the sync or touch my files?
No. A browser page has no access to your filesystem and no way to open an SSH session, so the only thing produced here is text. The executed outputs behind the examples come from this project's own fixture tree, generated on the golden host — never from anything you type.
Which delete mode should I start with?
None. Get the copy right first, then add plain --delete together with -n and read the deleting lines it prints. The timing variants only matter once you care when files vanish mid-run, and --delete-excluded is a separate decision because excluded files are otherwise protected.
Keyboard shortcuts
- ⌘/Ctrl + C
- Copy the command when nothing is selected and focus is in the tool.
- ⌘/Ctrl + Shift + C
- Copy the command even while text is selected.
- t
- Cycle theme.
- ? or ⌘/Ctrl + /
- Open the shortcut help overlay.
- Esc
- Close the overlay.