C.W.K.
Stream
Lesson 04 of 12 · published

rsync Essentials

~15 min · rsync, flags, archive-mode

Level 0Pinger
0 XP0/101 lessons0/12 achievements
0/150 XP to next level150 XP to go0% complete

The flag table you'll never need to look up again

FlagWhat it does
-aArchive mode — equivalent to -rlptgoD (recursive, preserve symlinks, perms, times, group, owner, devices)
-vVerbose — list files as they transfer
-zCompress in transit (drop on fast LAN)
--progress / -PPer-file progress bars (-P = --partial --progress)
-hHuman-readable sizes
-n / --dry-runShow what would happen without doing it
--deleteRemove files at destination missing from source
--excludeSkip matching files/dirs
--exclude-from=fileSkip patterns listed in a file
--partialKeep partial files for resume
--statsPrint transfer statistics at the end
--bwlimit=NThrottle to N KB/s
--checksumCompare by content not mtime+size (slower, more accurate)

Code

Daily recipes·bash
# Daily workhorse
rsync -avz --progress source/ dest/

# Dry run before any --delete
rsync -avzn --delete source/ dest/

# Sync to a backup, mirror exactly
rsync -avz --delete --stats source/ /Volumes/Backup/source/

# With exclusions
rsync -avz \
  --exclude '.git' --exclude 'node_modules' --exclude '.DS_Store' \
  source/ dest/

# Throttle on a metered network
rsync -avz --bwlimit=5000 source/ remote:/dest/   # ~5 MB/s cap

External links

Exercise

Pick a real project directory. Run rsync -avzh --stats --dry-run source/ host:/tmp/dest/ and read the stats — total files, total bytes, files transferred. Then run for real. Add --exclude '.git' --exclude 'node_modules' and observe the byte-count drop dramatically. These flags are how you stop wasting bandwidth on cruft.

Progress

Progress is local-only — sign in to sync across devices.
Spotted a bug or have feedback on this page?Report an Issue

Comments 0

🔔 Reply notifications (sign in)
Sign inPlease sign in to comment.

No comments yet — be the first.