Command builder

rsync command builder

Copy, sync, mirror or back up — without re-learning the flags. The two traps everyone hits, the trailing slash and --delete, are spelled out as you go. Pick a recipe, tweak, copy.

Recipe:
Common options
Safety & deletion
Excludes

Patterns to skip e.g. node_modules, *.log, .git

Transfer tuning
SSH (port & key)

Only used for Upload/Download. A non-default port or key adds -e 'ssh …'.

Command
 

The two footguns

The trailing slash on the source
This is the one that bites everyone. rsync -a src/ dest/ copies the contents of src into dest. rsync -a src dest/ (no slash) copies the folder itself, giving you dest/src/…. The destination's trailing slash doesn't matter — only the source's. The live hint above tells you which one you're about to run.
--delete — one-way mirror
Without it, rsync only adds and updates; files you removed from the source stay in the destination. --delete makes the destination an exact mirror by removing anything not in the source. That's also how people erase a backup by pointing the arguments the wrong way round. Always do a -n (dry run) first.

The flags, briefly

-a (archive)
The sensible default: recurse into directories and preserve permissions, timestamps, symlinks and ownership. It's shorthand for -rlptgoD. Almost every rsync command starts here.
-z (compress)
Compresses data in transit — worth it over slow networks, pointless for local copies or already-compressed files (video, archives, images).
-P (progress + partial)
Shows a live progress bar and keeps partially-transferred files so an interrupted big transfer can resume where it stopped.
-u / -c
-u skips files that are newer at the destination. -c decides what to send by checksum instead of the faster default (size + modification time) — slower, but catches same-size, same-time changes.

Note

rsync is a Unix tool — these commands run in bash/zsh on Linux and macOS, and on Windows via WSL or Git Bash. Paths are quoted only when they need it; ~ is left unquoted so your home directory still expands.

Sources & references