Rsync vs SCP — Choosing the Right Transfer Tool
Both rsync and scp use SSH for secure file transfers, but they solve different problems. This guide helps you choose the right tool for each situation.
SCP copies entire files every time. Rsync compares source and destination, then transfers only what changed. For repeated operations, rsync can be 10–100x faster.
Side-by-Side Comparison
| Feature | Rsync | SCP |
|---|---|---|
| Transfer Type | Delta-based (only changed blocks) | Full file copy (everything, every time) |
| Resume Interrupted Transfer | Yes (--partial) | No |
| Delete Extra Files (Mirror) | Yes (--delete) | No |
| Dry Run (Preview) | Yes (--dry-run) | No |
| Compression | Yes (-z) | Yes (-C) |
| Checksum Verification | Block-by-block checksums | Basic transfer ack only |
| Permission Preservation | Full (-a flag) | Basic (-p flag) |
| Recursive Directory Copy | Yes (-a or -r) | Yes (-r) |
| Bandwidth Efficiency | High (transfers only diffs) | Low (full retransfer) |
| Installed by Default | Usually (not always) | Yes (with OpenSSH) |
| Best For | Backups, sync, deployment | Quick one-time copies |
Syntax Comparison
| Operation | Rsync | SCP |
|---|---|---|
| Upload a file | rsync -avz file user@server:/path/ | scp file user@server:/path/ |
| Upload a directory | rsync -avz dir/ user@server:/path/ | scp -r dir/ user@server:/path/ |
| Download a file | rsync -avz user@server:/file ./ | scp user@server:/file ./ |
| Resume interrupted transfer | rsync -avzP file user@server:/path/ | Not supported |
| Mirror (delete extras) | rsync -avz --delete src/ user@server:/dest/ | Not supported |
| Preview changes | rsync -avz --dry-run src/ dest/ | Not supported |
When to Use Rsync
Rsync excels in repeated, automated, or large-scale file operations:
| Scenario | Why Rsync Wins |
|---|---|
| Daily server backups | Transfers only files that changed since the last backup |
| Application deployment | Syncs code changes without re-uploading the entire project |
| Server migration | Handles large directory trees efficiently with resume support |
| Staging ↔ Production sync | Keeps environments mirrored with --delete |
| Database dump backups | Incrementally syncs .sql or .sql.gz files |
| Configuration management | Syncs /etc/ configs or Docker files across multiple servers |
| Bandwidth-limited VPS | Minimizes network load through delta transfer |
Example: Daily Application Backup
# Sync web application to backup server (only changes transferred)
rsync -avz --delete /var/www/html/ user@backup-server:/backups/www/
# Sync database dumps
rsync -avzP /var/backups/mysql/ user@backup-server:/backups/mysql/
# Sync Nginx configs
rsync -av /etc/nginx/ user@backup-server:/backups/config/nginx/
When to Use SCP
SCP is best for quick, one-time, simple transfers:
| Scenario | Why SCP Wins |
|---|---|
| Quick one-time file copy | Simpler syntax — no flags required |
| Transferring compressed archives | .tar.gz, .sql.gz, .zip — already compressed, delta transfer doesn't help |
| Remote server lacks rsync | SCP comes with OpenSSH, always available |
| Sharing config files between colleagues | One-line command, intuitive |
| Emergency file recovery | Quick and reliable when speed matters |
Example: One-Time Transfers
# Copy a database dump to a remote server
scp /var/backups/database.sql.gz user@server:/backups/
# Grab a config file from a remote server
scp user@server:/etc/nginx/nginx.conf ./
# Send a script to a colleague's server
scp deploy.sh user@colleague-server:/tmp/
Performance: Why It Matters
First Transfer (No Existing Data at Destination)
Both tools perform similarly — everything must be sent:
Rsync: ████████████████████████ 1 GB sent (~60 seconds)
SCP: ████████████████████████ 1 GB sent (~60 seconds)
Subsequent Transfers (Small Changes)
This is where rsync dramatically outperforms scp:
Rsync: ██ 20 MB sent (~2 seconds)
SCP: ████████████████████████ 1 GB sent (~60 seconds)
| Metric | Rsync (Incremental) | SCP |
|---|---|---|
| Data transferred | ~20 MB (only changes) | ~1 GB (full re-upload) |
| Time | ~2 seconds | ~60 seconds |
| Network usage | Minimal | Full bandwidth |
| CPU usage | Slightly higher (checksum calc) | Moderate (straight copy) |
For a typical production web application with daily backups, rsync saves 95%+ bandwidth after the initial sync. This matters significantly on metered VPS connections.
Security Comparison
Both tools use SSH for encryption — there's no security difference in transport:
| Aspect | Rsync | SCP |
|---|---|---|
| Encryption | SSH tunnel | SSH tunnel |
| Authentication | SSH keys or password | SSH keys or password |
| Integrity Check | Strong (checksum verification) | Basic (transfer ack) |
| Default Port | 22 (SSH) | 22 (SSH) |
| Custom Port | -e "ssh -p 2222" | -P 2222 |
| Access Control | Can use rsyncd.conf for fine-grained control | SSH-level only |
Always use SSH key-based authentication for both rsync and scp in automated workflows. Never store passwords in scripts.
Decision Matrix
Use this table to quickly decide which tool fits your situation:
| Use Case | Tool | Command Example |
|---|---|---|
| Daily incremental backup | rsync | rsync -avz --delete /var/www/ user@backup:/backups/www/ |
| Mirror staging to production | rsync | rsync -avz --delete /var/www/ user@prod:/var/www/ |
| Copy a single archive | scp | scp backup.tar.gz user@server:/backups/ |
| Copy a database dump | scp | scp database.sql.gz user@server:/backups/ |
| Sync MySQL dumps daily | rsync | rsync -avzP /var/backups/db/ user@remote:/backups/db/ |
| Deploy PHP/Python app changes | rsync | rsync -avz --exclude='.env' /var/www/app/ user@prod:/var/www/app/ |
| Share a config file quickly | scp | scp nginx.conf user@server:/etc/nginx/ |
| Full server migration | rsync | rsync -avzP --delete / user@new-server:/ --exclude='/proc' --exclude='/sys' |
Why Rsync is Preferred for Server Administration
For ongoing server management tasks, rsync wins in almost every category:
- Delta sync algorithm — Ideal for large directories with frequent small changes (uploads, logs, application data)
- Automation-friendly — Clean integration with cron jobs, systemd timers, and bash scripts
- Safer operations —
--dry-runlets you preview every change before committing - Auditable — Supports detailed logging with
--log-file - Preserves everything — Archive mode (
-a) maintains permissions, ownership, timestamps, and symlinks - Resumable —
--partialand-Pflags let you pick up where you left off after network interruptions
Example: Automated Backup Alias
# Add to ~/.bashrc for quick server backups
alias backup-app='rsync -avz --delete /var/www/html/ user@backup:/backups/www/'
alias backup-db='rsync -avzP /var/backups/mysql/ user@backup:/backups/mysql/'
alias backup-config='rsync -av /etc/nginx/ user@backup:/backups/config/'
Why SCP Still Has Its Place
Don't dismiss scp entirely — it remains useful for:
- Universal availability — Works on any system with SSH, even if rsync isn't installed
- Zero learning curve — Intuitive syntax for simple copies
- Perfect for compressed files — Delta transfer offers no advantage on
.tar.gzor.zipfiles - Emergency transfers — When you need to copy something right now without thinking about flags
Quick Reference
# === Rsync Commands ===
# Sync directory to remote (incremental)
rsync -avz /source/ user@server:/destination/
# Mirror with deletion
rsync -avz --delete /source/ user@server:/destination/
# Resume interrupted transfer
rsync -avzP /source/ user@server:/destination/
# Preview changes (dry run)
rsync -avz --dry-run /source/ user@server:/destination/
# === SCP Commands ===
# Copy file to remote
scp file.tar.gz user@server:/destination/
# Copy directory to remote
scp -r directory/ user@server:/destination/
# Copy with compression
scp -C largefile user@server:/destination/
# Use non-standard SSH port
scp -P 2222 file user@server:/destination/
Bottom Line
| Criteria | Winner |
|---|---|
| Repeated syncs / backups | Rsync |
| One-time file copy | SCP |
| Bandwidth efficiency | Rsync |
| Simplicity | SCP |
| Automation / scripting | Rsync |
| Always available | SCP |
| Resume support | Rsync |
| Large directory management | Rsync |
Rule of thumb:
- Use rsync for anything you'll do more than once
- Use scp for quick, one-off transfers
What's Next
- Incremental Sync — See delta transfer in action
- Source and Destination — Master rsync path rules
- Options and Flags — Learn every essential rsync flag