Skip to main content

rsync Cheatsheet

rsync is a powerful file synchronization and transfer tool supporting efficient local and remote incremental sync. This cheatsheet covers basic usage, SSH remote sync, filter rules, and advanced options for data backup and migration.

Updated: 2026-07-16·30 commands

Basic Usage

Basic rsync syntax: rsync [options]

### Local Sync

``yaml # Basic local directory sync (archive mode, preserve permissions and timestamps) rsync -a /path/to/source/ /path/to/destination/

# Show transfer progress rsync -av /data/ /backup/

# Compress for reduced bandwidth rsync -az /data/ /backup/

# Human-readable numbers rsync -ah /data/ /backup/

# Common combined options: archive + compress + progress + human-readable rsync -avzP /data/ /backup/ `

### Incremental Transfer

`yaml # Transfer only differences (rsync default behavior) rsync -av /data/ /backup/

# Delete extraneous files from destination (mirror mode) rsync -av --delete /data/ /backup/

# Remove source files after transfer (move operation) rsync -av --remove-source-files /data/ /backup/ `

### Checking and Validation

`yaml # Dry run (simulate, no actual transfer) rsync -av --dry-run /data/ /backup/

# Use checksum instead of size+time for change detection rsync -avc /data/ /backup/ `

Remote Sync via SSH

Sync files between local and remote hosts over SSH.

### Push to Remote

`yaml # Push local to remote (default SSH) rsync -av /local/data/ user@remote:/remote/backup/

# Specify SSH port rsync -av -e "ssh -p 2222" /local/data/ user@remote:/remote/backup/

# Limit bandwidth (KB/s) rsync -av --bwlimit=1000 /local/data/ user@remote:/remote/backup/ `

### Pull from Remote

`yaml # Pull remote to local rsync -av user@remote:/remote/backup/ /local/data/

# Use SSH key rsync -av -e "ssh -i ~/.ssh/deploy_key" user@remote:/remote/backup/ /local/data/ `

### SSH Advanced Configuration

`yaml # Set SSH connection timeout (seconds) rsync -av -e "ssh -o ConnectTimeout=10" /local/data/ user@remote:/remote/backup/

# Custom SSH compression level rsync -avz -e "ssh -C" /local/data/ user@remote:/remote/backup/ `

Filter Rules

Use include/exclude rules to precisely control what gets synced.

### Exclude Patterns

`yaml # Exclude specific files or directories rsync -av --exclude='*.log' /data/ /backup/

# Exclude multiple patterns rsync -av --exclude='*.log' --exclude='node_modules/' --exclude='.git/' /project/ /backup/

# Include first, then exclude rest (whitelist mode) rsync -av --include='*/' --include='*.py' --exclude='*' /project/ /backup/

# Read exclude rules from a file rsync -av --exclude-from=exclude.txt /data/ /backup/ `

### Include Patterns

`yaml # Include only specific file types rsync -av --include='*/' --include='*.conf' --exclude='*' /etc/ /backup/

# Include a single file rsync -av --include='config.yml' --exclude='*' /project/ /backup/ `

### File List Sync

`yaml # Read file list from a file rsync -av --files-from=filelist.txt /data/ /backup/ `

Advanced Options

### Hardlink Incremental Backup

`yaml # Incremental backup with hardlinks to previous backup rsync -av --link-dest=/backup/prev-backup /data/ /backup/curr-backup/ `

### File Attribute Management

`yaml # Preserve owner and group rsync -av --owner --group /data/ /backup/

# Skip preserving owner rsync -av --no-owner /data/ /backup/

# Set file permissions via chmod mode rsync -av --chmod=Du=rwx,Dgo=rx,Fu=rw,Fgo=r /data/ /backup/ `

### Size and Timeout Limits

`yaml # Only sync files smaller than a size limit rsync -av --max-size=100M /data/ /backup/

# Only sync files larger than a size limit rsync -av --min-size=1K /data/ /backup/

# Set I/O timeout (seconds) rsync -av --timeout=30 /data/ /backup/ `

### rsync Daemon Mode

`yaml # Use rsync daemon protocol (rsync://) rsync -av rsync://rsync.example.com/mirror/ /local/mirror/

# List available daemon modules rsync rsync://rsync.example.com/ `

### rsyncd.conf Configuration

`yaml # /etc/rsyncd.conf example # [backup] # path = /var/backup # comment = Backup Directory # read only = no # auth users = backupuser # secrets file = /etc/rsyncd.secrets

# Connect to a password-protected rsync daemon rsync -av rsync://backupuser@rsync.example.com/backup/ /local/backup/ ``

Basic(8)

CommandLevel
rsync -a /path/to/source/ /path/to/destination/
Archive mode sync preserving permissions and timestamps
Basic
rsync -av /data/ /backup/
Archive mode with verbose output
Basic
rsync -az /data/ /backup/
Archive mode with compression
Basic
rsync -ah /data/ /backup/
Human-readable numeric output
Basic
rsync -avzP /data/ /backup/
Common combo: archive + compress + progress + partial
Basic
rsync -av --delete /data/ /backup/
Delete extraneous files at destination (mirror)
Intermediate
rsync -av --dry-run /data/ /backup/
Dry run without actual file transfer
Basic
rsync -avc /data/ /backup/
Use checksum for change detection
Intermediate

Remote Sync(6)

CommandLevel
rsync -av /local/data/ user@remote:/remote/backup/
Push files to remote host via SSH
Basic
rsync -av user@remote:/remote/backup/ /local/data/
Pull files from remote host via SSH
Basic
rsync -av -e "ssh -p 2222" /local/data/ user@remote:/remote/backup/
Sync over SSH with custom port
Intermediate
rsync -av -e "ssh -i ~/.ssh/deploy_key" user@remote:/source/ /dest/
Sync using a specific SSH key
Intermediate
rsync -av -e "ssh -o ConnectTimeout=10" /local/ user@remote:/remote/
Set SSH connection timeout
Intermediate
rsync -av --bwlimit=1000 /local/data/ user@remote:/remote/backup/
Limit bandwidth in KB/s
Intermediate

Filter(5)

CommandLevel
rsync -av --exclude='*.log' /data/ /backup/
Exclude files matching a pattern
Basic
rsync -av --exclude='*.log' --exclude='node_modules/' /project/ /backup/
Exclude multiple patterns
Basic
rsync -av --include='*/' --include='*.py' --exclude='*' /project/ /backup/
Whitelist mode: include only .py files
Expert
rsync -av --exclude-from=exclude.txt /data/ /backup/
Read exclude rules from a file
Intermediate
rsync -av --files-from=filelist.txt /data/ /backup/
Read file list to sync from a file
Intermediate

Advanced(11)

CommandLevel
rsync -av --link-dest=/backup/prev-backup /data/ /backup/curr-backup/
Hardlink-based incremental backup
Expert
rsync -av --remove-source-files /data/ /backup/
Remove source files after transfer (move)
Intermediate
rsync -av --chmod=Du=rwx,Dgo=rx,Fu=rw,Fgo=r /data/ /backup/
Set file permissions during transfer
Expert
rsync -av --max-size=100M /data/ /backup/
Limit maximum file size
Intermediate
rsync -av --min-size=1K /data/ /backup/
Limit minimum file size
Intermediate
rsync -av --timeout=30 /data/ /backup/
Set I/O timeout in seconds
Intermediate
rsync -av --owner --group /data/ /backup/
Preserve file owner and group
Intermediate
rsync -av --no-owner /data/ /backup/
Do not preserve file owner
Intermediate
rsync -av rsync://rsync.example.com/mirror/ /local/mirror/
Sync using rsync daemon protocol
Expert
rsync rsync://rsync.example.com/
List available rsync daemon modules
Expert
rsync -av --partial /data/ /backup/
Keep partially transferred files (resume)
Intermediate

FAQ

This cheatsheet is compiled from official tool documentation. Last updated: 2026-07-16.