
Photo by Domaintechnik Ledl.net on Unsplash
The 3-2-1 Backup Strategy for Homelabs
How to protect your data with proper backups using ZFS, PBS, and offsite storage.
The 3-2-1 Backup Strategy for Homelabs
Data loss is not a matter of if, but when. Hard drives fail, ransomware attacks happen, and accidents occur. The 3-2-1 backup strategy is your insurance policy against data loss.
What is 3-2-1?
The 3-2-1 rule is simple:
- 3 copies of your data
- 2 different storage media types
- 1 offsite backup
Let's break down how to implement this in a homelab environment.
The First Copy: Primary Storage
Your primary data lives on your main storage system. In our homelab, we use:
- ZFS - For data integrity and snapshots
- Proxmox VE - For VM and container storage
- TrueNAS - For file storage and media
ZFS Configuration Example
# Create a mirrored pool
zpool create tank mirror /dev/sda /dev/sdb
# Enable compression
zfs set compression=lz4 tank
# Create datasets
zfs create tank/vms
zfs create tank/containers
zfs create tank/files
The Second Copy: Local Backup
Your local backup should be on different media from your primary storage. Options include:
- A separate NAS device
- External hard drives
- A dedicated backup server
Proxmox Backup Server
PBS is our go-to solution for VM and container backups:
# Example backup job in PBS
proxmox-backup-client backup \
vm/100.pxar:/path/to/vm \
--repository user@pbs:datastore
Automated Snapshots
Schedule regular ZFS snapshots:
# Create a snapshot
zfs snapshot tank/files@$(date +%Y-%m-%d)
# List snapshots
zfs list -t snapshot
The Third Copy: Offsite Backup
Offsite backup protects against physical disasters. Options include:
- Cloud Storage - Backblaze B2, Wasabi, or AWS S3
- Remote Location - A friend's house or office
- Safety Deposit Box - For critical archives
Restic to Backblaze B2
# Initialize repository
restic -r b2:bucket-name:path init
# Backup
restic -r b2:bucket-name:path backup /path/to/data
# Prune old backups
restic -r b2:bucket-name:path forget --keep-last 7 --keep-weekly 4 --prune
Monitoring and Testing
Backups are worthless if they don't work. Implement:
- Backup Monitoring - Alert on failures
- Regular Test Restores - Quarterly at minimum
- Documentation - Know your recovery procedures
Simple Monitoring Script
#!/bin/bash
BACKUP_DIR="/mnt/backups"
MAX_AGE=86400 # 24 hours
latest=$(find $BACKUP_DIR -type f -mtime -1 | head -1)
if [ -z "$latest" ]; then
echo "ALERT: No recent backups found!"
# Send notification
fi
Our Backup Stack
Here's what we use in our homelab:
| Layer | Tool | Destination | |-------|------|-------------| | VM/CT Backups | Proxmox Backup Server | Local NAS | | File Sync | Syncthing | Secondary NAS | | Offsite | Restic + rclone | Backblaze B2 | | Snapshots | ZFS | Local |
Key Takeaways
- Automate everything - Manual backups don't happen
- Test regularly - Untested backups are not backups
- Encrypt offsite - Protect data in transit and at rest
- Document recovery - Know how to restore before you need to
Remember: RAID is not a backup. Snapshots alone are not a backup. Only the 3-2-1 strategy gives you true data protection.
Was this article helpful?