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;srccopies the dir itself.
Common flags
-aarchive (recursive, preserve)-vverbose,-hhuman-zcompress over network--deletemake dest mirror src (dangerous; use with--dry-runfirst)--progressshow 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/