Skip to main content

rsync

Fast incremental file transfer and synchronization.

Basics

  • Dry-run with stats
rsync -avh --dry-run --stats src/ dest/
  • Local copy (preserve perms, times)
rsync -a src/ dest/
  • Remote copy over SSH
rsync -avz -e ssh src/ user@host:/path/

Trailing slash semantics

  • src/ copies contents of dir; src copies the dir itself.

Common flags

  • -a archive (recursive, preserve)
  • -v verbose, -h human
  • -z compress over network
  • --delete make dest mirror src (dangerous; use with --dry-run first)
  • --progress show progress

Examples

  • Mirror to remote, delete extras
rsync -avz --delete src/ user@host:/srv/app/
  • Exclude patterns
rsync -av --exclude '.git/' --exclude '*.log' src/ dest/
  • Partial + resume
rsync -av --partial --inplace src/ dest/
  • Use SSH port and key
rsync -avz -e 'ssh -p 2222 -i ~/.ssh/id_ed25519' src/ user@host:/path/

Checksum-based

  • Force checksum comparison (slower)
rsync -avc src/ dest/

Pull from remote

  • Remote to local
rsync -avz user@host:/path/data/ ./data/