Back to Blog

The 3-2-1 Backup Strategy for Your Homelab

Protect your homelab data with the proven 3-2-1 backup strategy. Learn how to implement automated backups with practical examples and tools.

Posted by

Data backup and recovery concept

Data Loss is Not an Option

Your homelab stores irreplaceable data - family photos, important documents, years of configuration work. A single drive failure, ransomware attack, or accidental deletion could wipe it all out.

The 3-2-1 backup strategy is the industry standard for protecting data. Here's how to implement it for your homelab.

The 3-2-1 Rule Explained

  • 3 copies of your data (original + 2 backups)
  • 2 different storage types (SSD + HDD, local + cloud)
  • 1 offsite copy (protects against fire, theft, disaster)

Layer 1: Local Backups

Fast recovery for common issues like accidental deletion:

# Using Restic for local backup
# Install: apt install restic

# Initialize repository
restic init --repo /backup/restic-repo

# Backup Docker volumes
restic backup /var/lib/docker/volumes --repo /backup/restic-repo

# Automate with cron
0 2 * * * restic backup /var/lib/docker/volumes --repo /backup/restic-repo

Layer 2: External Drive

A different storage medium protects against drive failures:

  • Use a USB external HDD
  • Schedule weekly full backups
  • Consider rotation (multiple drives)
# Backup to external drive with rsync
rsync -avz --delete /important/data /mnt/external-drive/backup/

# Or use Restic to external drive
restic backup /important/data --repo /mnt/external-drive/restic

Layer 3: Offsite/Cloud

Protects against catastrophic local events:

Option A: Cloud Storage (Backblaze B2)

# Configure Restic with Backblaze B2
export B2_ACCOUNT_ID="your_account_id"
export B2_ACCOUNT_KEY="your_account_key"

restic init --repo b2:bucket-name:restic
restic backup /important/data --repo b2:bucket-name:restic

Option B: Another Location

  • Family member's house with a Pi
  • Office server
  • Cheap VPS for backup storage

Docker Volume Backup Script

#!/bin/bash
# backup-docker.sh

BACKUP_DIR="/backup/docker-$(date +%Y%m%d)"
mkdir -p $BACKUP_DIR

# Stop containers, backup, restart
for container in $(docker ps -q); do
  name=$(docker inspect --format='{{.Name}}' $container | tr -d '/')
  docker stop $container

  # Backup volumes
  docker run --rm \
    -v $name:/data \
    -v $BACKUP_DIR:/backup \
    alpine tar czf /backup/$name.tar.gz /data

  docker start $container
done

# Keep 7 days of backups
find /backup -type d -name "docker-*" -mtime +7 -exec rm -rf {} \;

Test Your Backups!

A backup you haven't tested is not a backup. Regularly:

  • Restore a random file monthly
  • Do a full restore test quarterly
  • Verify backup integrity with checksums
  • Document your restore procedures

Backup Tools for Homelab

  • Restic: Modern, encrypted, deduplicated backups
  • Borg: Similar to Restic, more mature
  • Duplicati: GUI-based with cloud support
  • rsync: Simple and reliable
  • Proxmox Backup Server: Great for Proxmox users

Peace of Mind

Implementing 3-2-1 takes a few hours but provides peace of mind for years. Your photos, documents, and configurations are protected against any disaster. Don't wait for data loss to make backups a priority.

Continue Reading