Sync folders locally or over SSH, mirror, and back up — only copying what changed. Tap to copy.
rsync -av source/ dest/Sync a directory (archive mode, verbose)rsync -avz source/ user@host:/dest/Sync to a remote server, compressedrsync -avz user@host:/src/ ./dest/Pull from a remote serverrsync -av --delete source/ dest/Mirror: remove files missing from sourcersync -avn source/ dest/Dry run — show what would changersync -avP source/ dest/Show progress and keep partial filesrsync -avh source/ dest/Human-readable sizes in the outputrsync -av --stats source/ dest/Print a transfer summary at the endrsync -av --exclude='*.log' src/ dst/Skip files matching a patternrsync -av --exclude-from=skip.txt src/ d/Read exclude patterns from a filersync -av -e 'ssh -p 2222' src/ host:/d/Use a non-standard SSH portrsync -av --bwlimit=2000 src/ dst/Throttle bandwidth (KB/s)rsync -avz --partial src/ host:/d/Resume interrupted transfersrsync -a --link-dest=../prev curr/ new/Incremental backup using hard linksrsync -avz --delete-after src/ host:/d/Mirror, deleting only after copyingrsync copies files, but its trick is that it only transfers the differences — on a second run it skips everything that hasn't changed, making repeat syncs and backups dramatically faster than copying from scratch. The workhorse flag is -a ("archive"), which preserves permissions, timestamps, symlinks and ownership in one letter. Add -v for verbose output and, for network transfers, -z to compress data in flight. rsync -avz is the combination you'll type most.
The single most common rsync confusion is the trailing slash on the source. rsync -av source/ dest/ copies the contents of source into dest, whereas rsync -av source dest/ copies the source folder itself, creating dest/source/. It's worth pausing on this every time, because getting it wrong nests a folder one level too deep. The destination's trailing slash, by contrast, doesn't change the behaviour.
Two options turn rsync into a backup tool. --delete makes the destination an exact mirror by removing files that no longer exist in the source — powerful, and exactly why you should preview with -n (dry run) first so a wrong path doesn't wipe the wrong folder. For versioned backups, --link-dest points at the previous backup and hard-links unchanged files, so each snapshot looks complete but only the changed files take up new space. rsync works seamlessly over SSH, so the same commands back up to a remote server. Pair it with the SSH commands for the connection and tar for one-off archives.