This page is not available in every language. Missing translations are disabled in the language selector.

Quick reference

Rsync Cheatsheet

A quick reference guide for Rsync: incremental file transfers, remote SSH synchronization, directory mirroring, exclusions, and bandwidth throttling.

· Published

rsync is a fast and versatile incremental file-copying tool for local and remote file synchronization over SSH.

Trailing Slash Convention

[!IMPORTANT] Trailing Slash Matters:

  • src (without trailing slash): copies the directory itself (dest/src/files).
  • src/ (with trailing slash): copies only the contents inside src (dest/files).
# Sync contents of src directory into dest
rsync -avz ./src/ /var/backup/

Common Flag Combinations

# Standard archive sync with progress (-a: archive, -v: verbose, -z: compress, -h: human-readable)
rsync -avzh source/ [email protected]:/target/

# Mirror directory (deletes files in target that no longer exist in source)
rsync -avzh --delete source/ target/

# Dry run: preview changes without writing files
rsync -avzh --dry-run source/ target/

Exclusions & SSH Port

# Exclude git directories and node_modules
rsync -avz --exclude '.git' --exclude 'node_modules' ./src/ user@server:/app/

# Use non-standard SSH port (e.g. port 2222)
rsync -avz -e 'ssh -p 2222' ./dist/ user@remote:/www/

Bandwidth Limiting

# Limit transfer bandwidth to 5000 KB/s
rsync -avz --bwlimit=5000 large_dataset.tar remote:/backups/

References

Related topics