Reliable backups are the foundation of any solid infrastructure. Linux offers several powerful backup tools, each with unique strengths. This guide compares rsync, Borg Backup, and Restic to help you choose the right tool for your needs.
Tool Overview
- rsync: File synchronization tool. Simple, fast, and universally available.
- Borg Backup: Deduplicating backup tool with compression and encryption.
- Restic: Modern backup tool with built-in cloud storage support.
rsync: The Classic Approach
# Basic local backup
rsync -avz --progress /home/user/ /backup/home/
# Remote backup over SSH
rsync -avz --progress -e ssh /var/www/ user@backup-server:/backups/www/
# Incremental backup with hard links
rsync -avz --delete --link-dest=/backup/daily.1 /data/ /backup/daily.0/
# Exclude patterns
rsync -avz --exclude='*.log' --exclude='.cache' --exclude='node_modules' /project/ /backup/project/
Borg Backup: Deduplication and Encryption
# Initialize encrypted repository
borg init --encryption=repokey /backup/borg-repo
# Create a backup
borg create --stats --progress /backup/borg-repo::daily-{now:%Y-%m-%d} \
/home /etc /var/www \
--exclude '*.pyc' \
--exclude '/home/*/.cache'
# List archives
borg list /backup/borg-repo
# Prune old backups (keep 7 daily, 4 weekly, 6 monthly)
borg prune --keep-daily=7 --keep-weekly=4 --keep-monthly=6 /backup/borg-repo
# Restore files
borg extract /backup/borg-repo::daily-2026-03-05 home/user/documents
Restic: Modern Cloud-Native Backup
# Initialize repository (local)
restic init --repo /backup/restic-repo
# Initialize repository (S3)
export AWS_ACCESS_KEY_ID=your-key
export AWS_SECRET_ACCESS_KEY=your-secret
restic init --repo s3:s3.amazonaws.com/my-backup-bucket
# Create backup
restic backup /home /etc /var/www --exclude-caches
# List snapshots
restic snapshots
# Forget and prune old snapshots
restic forget --keep-daily 7 --keep-weekly 4 --keep-monthly 6 --prune
# Restore
restic restore latest --target /restore/
Feature Comparison
| Feature | rsync | Borg | Restic |
|---|---|---|---|
| Deduplication | No | Yes | Yes |
| Encryption | SSH only | AES-256 | AES-256 |
| Compression | Basic | LZ4/ZSTD/LZMA | No (at repo level) |
| Cloud Storage | No | SSH only | S3/Azure/GCS/B2 |
| Speed | Fast | Fast | Moderate |
| Complexity | Simple | Moderate | Simple |
Automation Script Example (Borg)
#!/bin/bash
# /usr/local/bin/backup.sh
export BORG_REPO="/backup/borg-repo"
export BORG_PASSPHRASE="your-secure-passphrase"
LOG="/var/log/borg-backup.log"
echo "$(date) - Starting backup" >> "$LOG"
borg create --stats \
"$BORG_REPO"::auto-{now:%Y-%m-%d_%H:%M} \
/home /etc /var/www /var/lib/postgresql \
--exclude '*.tmp' \
--exclude '/home/*/.cache' \
2>&1 >> "$LOG"
borg prune --keep-daily=7 --keep-weekly=4 --keep-monthly=12 \
"$BORG_REPO" 2>&1 >> "$LOG"
borg compact "$BORG_REPO" 2>&1 >> "$LOG"
echo "$(date) - Backup completed" >> "$LOG"
Recommendations
- Use rsync for simple file synchronization and mirroring between servers
- Use Borg for local or SSH-based backups with deduplication and encryption
- Use Restic when you need cloud storage backends like S3, Azure, or Backblaze B2
The best backup tool is the one you actually use consistently. Pick the tool that fits your infrastructure, automate it thoroughly, and test your restores regularly.