ops@toolbox:~$ rsynccommandexamples --run

rsync Command Examples

The rsync invocations that matter: mirror, dry-run, delete, resume, bandwidth limits.

CommandWhat it does
rsync -av src/ dest/Archive mode (permissions, times, symlinks, recursion) with verbosity. The everyday sync.
rsync -avn src/ dest/Dry run (n): show what would change, transfer nothing. Run this before any -av --delete.
rsync -av --delete src/ dest/True mirror: also remove files from dest that no longer exist in src. Powerful; dry-run first.
rsync -av src/ user@host:/backup/Push over SSH. Trailing slash on src = copy contents; no slash = copy the directory itself. The most consequential character in rsync.
rsync -av user@host:/var/log/ ./logs/Pull from a remote host.
rsync -avz src/ host:/dest/Compress in transit (z), helps on slow WAN links, wastes CPU on fast LANs.
rsync -av --partial --progress big.iso host:/data/Resume-friendly large file transfer with a progress meter (-P = --partial --progress).
rsync -av --exclude='*.tmp' --exclude='.git/' src/ dest/Skip patterns. Order matters when mixing includes and excludes.
rsync -av --exclude-from=.rsyncignore src/ dest/Read exclude patterns from a file.
rsync -av --bwlimit=10M src/ host:/dest/Cap bandwidth so a backup doesn't saturate the office uplink.
rsync -av --link-dest=../daily.1 src/ daily.0/Incremental snapshots via hardlinks: unchanged files cost no space. The trick behind many backup tools.
rsync -av -e 'ssh -p 2222 -i /root/backup_key' src/ host:/dest/Custom SSH transport: port, identity, options.
rsync -av --checksum src/ dest/Compare by checksum, not size+mtime. Slow (reads everything) but definitive after suspected corruption.
rsync -av --remove-source-files src/ dest/Move semantics: delete each source file after successful transfer (leaves empty dirs).

Why rsync over cp and scp

rsync transfers only what changed, by default anything whose size or modification time differs, and within large files only the changed blocks (the rolling-checksum delta algorithm). A nightly sync of a 100 GB tree where 200 MB changed moves roughly 200 MB. It's also restartable, preserves metadata faithfully, and reports exactly what it did. scp is fine for one file; for trees, rsync every time, and since OpenSSH 9's scp actually uses the SFTP protocol, the historical speed argument is gone too.

The trailing slash, tattooed here

rsync -av src dest/ creates dest/src/…; rsync -av src/ dest/ puts src's contents directly in dest/. With --delete in play, the wrong variant doesn't just misplace files; it deletes everything in dest that doesn't match the unexpected layout. This is the origin of most rsync horror stories, and the reason -n (dry run) before any deleting sync is a rule, not a suggestion.

Flags worth knowing exist

--link-dest turns rsync into a snapshot backup engine: each day's directory looks complete, but unchanged files are hardlinks to yesterday's copy, costing zero extra space. --partial keeps interrupted transfers for resumption instead of deleting them. -H preserves hardlinks (off by default, surprising for system backups), -x stays on one filesystem (don't back up /proc), and --info=progress2 gives whole-transfer progress rather than per-file. Add -A -X when ACLs and extended attributes matter, plain -a does not include them.

Related tools

DNS Record Types
Searchable reference of DNS record types with practical notes.
HTTP Headers Reference
Searchable reference of the HTTP request and response headers that matter in operations.
Linux Signals Reference
kill -9 and friends: every signal a sysadmin meets, with default actions and notes.
tar Command Examples
The tar invocations you actually need: create, extract, list, compress, exclude.