The right tool for almost every copy
rsync copies files between two locations (local-local, local-remote, remote-remote) but only transfers what changed. It preserves permissions, handles symlinks, can resume after a network blip, and tells you exactly what it did.
The flag set you'll always type
rsync -avzP src/ dest/
-a— archive (recursion, perms, times, symlinks).-v— verbose, list each file.-z— compress over the wire.-P— partial+progress (resumable, shows progress per file).
The trailing-slash rule
rsync -av src/ dest/— copy contents of src into dest.rsync -av src dest/— copy src itself into dest, creatingdest/src/.
Trailing slash on the source is the one decision you make before every rsync.
Useful extras
--delete— remove files in dest that aren't in src. Mirror mode. Use with care.--exclude='node_modules' --exclude='.git'— skip patterns.--exclude-from=.rsyncignore— read patterns from a file.--dry-run(or-n) — show what would happen without doing it. Always run with -n first.-e ssh— explicit transport (defaults to ssh nowadays).
Real patterns
- Backup home:
rsync -avzP ~/ /Volumes/backup/home/ - Mirror to remote:
rsync -avzP --delete ./site/ user@web:/srv/site/ - Pull from remote:
rsync -avzP user@server:/data/ ~/local-data/