rsync Command Builder
Build a correct rsync command without guessing at flag order or quoting. Choose archive mode, compression, delete, dry-run and exclude patterns; add an SSH shell for remote transfers. The builder notes the trailing-slash gotcha on the source path — one of rsync\'s most common footguns — so you know what will actually be copied.
How to use the rsync Command Builder
Enter the source and destination paths. A local path is a filesystem path like /home/user/project/. A remote path uses user@host:/remote/path/ syntax. If a path contains spaces, add quotes manually around it in the output.
Archive mode (-a) is equivalent to -rlptgoD: recursive, preserve symlinks, permissions, timestamps, group, owner and device files. It is the right default for any backup or deployment scenario. Compress (-z) reduces bandwidth but adds CPU overhead — skip it on a LAN.
Delete (--delete) removes files from the destination that no longer exist in the source. This is essential for true mirroring but destructive — always test with Dry run first. Dry run (-n) shows exactly what would be transferred without touching anything.
Enter exclude patterns one per line: *.log, .git, node_modules. Each becomes a separate --exclude='...' argument. The optional SSH field sets the remote shell via -e 'ssh ...' — use this to specify a non-standard port or identity file.
Trailing slash on the source: rsync -a /src/ /dest/ copies the contents of src into dest. rsync -a /src /dest/ (no trailing slash) copies the directory itself, creating /dest/src/. The builder warns you when neither path ends with a slash.
About rsync
rsync (Remote Sync) is a file-copying utility that uses a delta-transfer algorithm: on subsequent runs it compares file checksums and modification times and transfers only the changed bytes rather than entire files. For large directories that change incrementally — build artefacts, media libraries, database dumps — this makes repeated syncs dramatically faster than scp or cp.
rsync can operate locally (source and dest are both local paths), over SSH (one or both paths use user@host: syntax), or via the native rsync daemon protocol (paths starting with ::). The SSH transport is the most common for server deployments because it reuses existing SSH infrastructure and key-based authentication. The -e flag lets you pass custom SSH options, notably a non-standard port (ssh -p 2222) or a specific identity file.
The trailing-slash rule is rsync's most notorious gotcha: rsync /src/ /dest/ syncs the contents of src, while rsync /src /dest/ creates /dest/src/. This asymmetry does not apply to the destination. Understanding this distinction prevents accidentally duplicating directory levels in your target. Combined with --delete, a wrong source path can also delete correct files on the destination — always validate with -n first.
Common use cases
- Incremental server backups — archive a web root to a backup server over SSH nightly; only changed files are transferred.
- Deployment pipelines — push a built frontend dist/ to a production server, using --delete to remove stale assets and --exclude to skip source maps.
- Local directory mirroring — mirror a large photo or dataset directory to an external drive, resuming interrupted transfers with --partial.
- Cross-server migrations — move a site between hosts by rsyncing files, then replaying database dumps; repeat rsync before DNS cutover to minimise downtime.
- Bandwidth-constrained transfers — add -z to compress in transit when copying between data centres over metered connections.