🎁 New User? Get 20% off your first purchase with code NEWUSER20 Register Now →
Menu

Categories

Automated Backup Solutions for Linux: rsync, Borg, and Restic Compared

Automated Backup Solutions for Linux: rsync, Borg, and Restic Compared

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

FeaturersyncBorgRestic
DeduplicationNoYesYes
EncryptionSSH onlyAES-256AES-256
CompressionBasicLZ4/ZSTD/LZMANo (at repo level)
Cloud StorageNoSSH onlyS3/Azure/GCS/B2
SpeedFastFastModerate
ComplexitySimpleModerateSimple

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.

Share this article:
Mikkel Sorensen
About the Author

Mikkel Sorensen

UX/UI Design, Java Development, User-Centered Application Design, Technical Documentation

Mikkel Sørensen is a UX/UI-focused software developer with a strong background in Java-based application development.

He works at the intersection of user experience design and software engineering, creating applications that are both technically robust and user-centered. His experience includes interface design, inter...

UX Design UI Design Java Applications User Experience Engineering Accessibility Basics

Stay Updated

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