Guide
rsync and scp commands for backups and deployments
rsync is the standard tool for copying folders between machines when you will do it more than once: it compares both sides and sends only what changed, can resume interrupted transfers and runs over SSH. Its flags are powerful and a little unforgiving, especially --delete and the trailing slash. This builder writes rsync or scp commands from a form and explains the parts that surprise people.
How rsync decides what to send
By default rsync compares each file’s size and modification time on both sides and skips files that match. For files that differ, its delta algorithm sends only the changed blocks, which makes repeated backups and deployments fast even over slow links. With -c, it compares full checksums instead, which is slower but catches files whose content changed without a new timestamp.
The flags that matter
-a, archive mode, copies recursively and keeps permissions, times, symbolic links and ownership where possible; it is the right default. -z compresses data in transit, useful over the internet and wasteful on a local network. -h prints sizes in human units. --info=progress2 shows overall progress rather than a line per file, and --partial keeps partly transferred files so an interrupted copy resumes. --bwlimit caps bandwidth in KiB per second, and each exclude pattern becomes its own --exclude.
–delete and dry runs
--delete removes files from the destination that no longer exist in the source, which keeps a mirror or a deployed site clean. It is also how people wipe the wrong folder. The builder warns whenever delete is on without a dry run; run once with --dry-run, read the list of files rsync would delete, and only then run it for real. --backup-dir adds a safety net by moving replaced and deleted files into a separate folder instead of discarding them.
The trailing slash
On the source, a trailing slash means “the contents of this folder”. rsync -a dist/ server:/var/www/site/ puts the files from dist directly into site. Without the slash, rsync -a dist server:/var/www/site/ creates site/dist. The builder detects a source without a slash and explains what will happen; the destination’s slash makes no difference.
SSH options and scp
When one side is remote, rsync runs over SSH. A non-standard port and a specific key are passed with -e 'ssh -p 2222 -i ~/.ssh/deploy'. If the host is already set up in ~/.ssh/config, its alias works too. scp mode writes the simpler scp -rp equivalent, converting the bandwidth limit to the kilobits per second that scp’s -l expects, but scp always copies everything and cannot delete, so rsync is better for anything repeated.
A worked example
With the defaults, the builder produces rsync -azh --info=progress2 --partial --delete --dry-run --exclude=.git --exclude=.DS_Store --exclude=node_modules -e 'ssh -i ~/.ssh/deploy_ed25519' ./public/ [email protected]:/var/www/site/. It uploads the contents of public to the site folder, skips Git data and editor clutter, and, because of the dry run, only lists what it would copy and delete. Unticking dry run turns it into the real deployment.
Scheduling a backup
The panel under the command also shows a crontab line that runs the same transfer every night at 02:00, with the dry-run and progress flags removed and output appended to a log. Key-based SSH authentication without a passphrase prompt, or a running agent, is needed for unattended runs.
Related tools
- SSH Config Generator gives the server a short alias and key.
- Linux Command Builder creates tar archives for off-site copies.
- Crontab Generator schedules the command with locking.
- TAR Extractor opens archives you downloaded from a server.
Checked against the current version of the rsync Command Builder on .

