šŸŽ New User? Get 20% off your first purchase with code NEWUSER20 Register Now →
Menu

Categories

Linux Backup Strategies with rsync and Borg: Complete Guide (2026)

Linux Backup Strategies with rsync and Borg: Complete Guide (2026)

Quick Summary: A solid backup strategy is the last line of defense against data loss from hardware failure, ransomware, human error, or natural disasters. rsync provides fast incremental file synchronization, while Borg Backup adds deduplication, compression, and encryption for efficient, secure long-term storage. Together, they form a comprehensive Linux backup solution.

Linux backup automation with rsync and Borg

The 3-2-1 Backup Rule

Every backup strategy should follow the 3-2-1 rule:

  • 3 copies of your data (original + 2 backups)
  • 2 different storage media (local disk + remote/cloud)
  • 1 copy offsite (different physical location)

rsync: Fast Incremental Synchronization

Essential rsync Commands

  • rsync -avz /source/ /backup/ — Archive mode, verbose, compressed
  • rsync -avz --delete /source/ /backup/ — Mirror (delete files removed from source)
  • rsync -avz -e "ssh -p 2222" /source/ user@remote:/backup/ — Remote backup via SSH
  • rsync -avz --exclude="*.log" --exclude="cache/" /source/ /backup/ — Exclude patterns
  • rsync --dry-run -avz /source/ /backup/ — Test without making changes

rsync Flags Explained

FlagMeaning
-aArchive mode (preserves permissions, timestamps, symlinks)
-vVerbose output
-zCompress data during transfer
--deleteRemove files from destination not in source
--progressShow transfer progress per file
--bwlimit=5000Limit bandwidth to 5MB/s
-nDry run (simulate without changes)

Borg Backup: Deduplicated, Encrypted Backups

Borg Backup is a modern backup tool that excels at space-efficient, encrypted backups:

Setting Up Borg

  1. Install: sudo apt install borgbackup or sudo dnf install borgbackup
  2. Initialize a repository: borg init --encryption=repokey /backup/borg-repo
  3. Create a backup: borg create /backup/borg-repo::daily-{now} /var/www /etc /home
  4. List archives: borg list /backup/borg-repo
  5. Restore files: borg extract /backup/borg-repo::daily-2026-03-25

Borg Key Features

FeatureBenefit
DeduplicationOnly stores unique data blocks — 10 backups of 100GB may use only 110GB
Compressionlz4, zstd, zlib — reduces storage by 30-60%
EncryptionAES-256 — backups are secure even on untrusted storage
PruningAutomatic retention policies (keep 7 daily, 4 weekly, 12 monthly)
Integrity checksborg check verifies backup consistency

rsync vs Borg Comparison

FeaturersyncBorg
DeduplicationNo (file-level only)Yes (block-level)
EncryptionNo (use SSH for transport)Yes (at-rest encryption)
CompressionTransfer onlyStorage compression
VersioningManual (hardlink rotation)Built-in archive system
SpeedVery fast (incremental)Fast (dedup overhead)
ComplexitySimpleModerate
Best forSimple mirrors, file syncLong-term versioned backups

Automating Backups

Create a backup script and schedule it with cron or systemd timers:

  1. Write a script that runs borg create with appropriate paths
  2. Add borg prune for retention policy
  3. Add borg check for integrity verification
  4. Log output with timestamps
  5. Schedule with cron: run daily at 2 AM
  6. Set up email alerts for failures

Frequently Asked Questions

How often should I back up?

Critical data: daily minimum, hourly for databases. With Borg's deduplication, daily backups of large datasets consume minimal additional storage. The cost of frequent backups is low compared to the cost of data loss.

Should I use rsync or Borg?

Use rsync for simple file synchronization between servers (mirroring). Use Borg for versioned backups with deduplication and encryption. Many setups use both: rsync for real-time replication, Borg for daily versioned backups.

How do I verify my backups work?

Regularly test restoring from backups. Run borg check for integrity verification. Schedule monthly test restores to a separate location. A backup you have never tested is not a backup — it is a hope.

Related Resources

Share this article:
Dargslan Editorial Team (Dargslan)
About the Author

Dargslan Editorial Team (Dargslan)

Collective of Software Developers, System Administrators, DevOps Engineers, and IT Authors

Dargslan is an independent technology publishing collective formed by experienced software developers, system administrators, and IT specialists.

The Dargslan editorial team works collaboratively to create practical, hands-on technology books focused on real-world use cases. Each publication is developed, reviewed, and...

Programming Languages Linux Administration Web Development Cybersecurity Networking

Stay Updated

Subscribe to our newsletter for the latest tutorials, tips, and exclusive offers.