A homelab without tested backups is a collection of services waiting for one disk failure. Restic is a practical fit for home servers: encrypted, deduplicated snapshots that can go to local disks, a NAS, or object storage, with retention rules that prevent old backups from filling the drive.
This guide builds a backup routine around Docker volumes and bind mounts, adds an offsite copy, and focuses on the part most people skip: proving that restores work. It complements our homelab security essentials and homelab cost guide.
What to back up
Start by separating replaceable containers from irreplaceable data. Container images can be pulled again. These cannot:
- Application databases and uploads
- Photos, documents, and personal media
- Configuration files and secrets inventory
- TLS, DNS, identity, and reverse-proxy settings
- Automation scripts and infrastructure notes
List every stateful service, its volumes, and its restore priority. A backup plan without that inventory usually protects the easy directories and misses the important ones.
Why Restic
Restic supports encryption by default, deduplication across snapshots, multiple backends, and straightforward prune policies. It works well from cron or systemd timers and does not require a dedicated backup server for a small setup.
The essential workflow is:
- Initialize an encrypted repository.
- Take regular snapshots.
- Copy snapshots to a second location.
- Apply retention rules.
- Test restores on a schedule.
Tools change; this discipline does not.
Prepare the repository
Choose a repository password and store it in a password manager and an offline location. Losing the password means losing every snapshot in that repository.
Initialize a local repository:
export RESTIC_REPOSITORY=/mnt/backup/restic-homelab
export RESTIC_PASSWORD_FILE=/root/.restic-password
restic init
Use a password file with restricted permissions rather than passing secrets on the command line. Keep the repository outside the same disk that holds production data whenever possible.
A Docker-friendly backup script
The simplest reliable method is to stop or pause only stateful services when required, snapshot their volumes and bind mounts, then bring everything back. Many databases support online dumps, which avoids downtime.
#!/usr/bin/env bash
set -euo pipefail
export RESTIC_REPOSITORY="/mnt/backup/restic-homelab"
export RESTIC_PASSWORD_FILE="/root/.restic-password"
BACKUP_SOURCES=(
"/home/ubuntu/services"
"/var/lib/docker/volumes/nextcloud_data"
"/var/lib/docker/volumes/immich_data"
)
echo "Creating database dumps..."
docker compose -f /home/ubuntu/services/app/compose.yaml exec -T db \
pg_dump -U app app | gzip > /home/ubuntu/services/backups/app-$(date +%F).sql.gz
echo "Running restic backup..."
restic backup "${BACKUP_SOURCES[@]}" \
--tag homelab \
--tag "$(date +%F)"
echo "Checking repository..."
restic check --read-subset=5%
Adapt paths to your server. Prefer application-native dumps for databases, then include both the dump and the volume in the snapshot when storage allows.
Retention that does not fill the disk
Unlimited snapshots eventually exhaust storage. A common starting policy keeps recent history while thinning older backups:
restic forget --prune \
--keep-daily 7 \
--keep-weekly 4 \
--keep-monthly 6
Run retention after successful backups, not before. Monitor repository size and backup duration. A growing backup that suddenly shrinks deserves investigation, not celebration.
Add an offsite copy
One local copy protects against accidental deletion, but not fire, theft, flooding, or a failed NAS. Copy snapshots to a second backend such as object storage, a remote server, or an encrypted USB drive stored elsewhere.
Restic can copy between repositories:
export RESTIC_REPOSITORY=/mnt/backup/restic-homelab
export RESTIC_PASSWORD_FILE=/root/.restic-password
restic copy --repo2 s3:https://s3.example.com/homelab-backup \
--password-file2 /root/.restic-remote-password
Automate the copy and alert on failure. An offsite job that silently stopped six months ago is worse than no offsite job because it creates false confidence.
Automate and monitor
Run backups from cron or a systemd timer. Log output, check exit codes, and send alerts on failure. A backup job without monitoring is a hope, not a system.
A minimal cron example:
0 2 * * * /usr/local/bin/homelab-backup.sh >> /var/log/homelab-backup.log 2>&1
Track these signals:
- Last successful snapshot timestamp
- Repository size and growth
- Failed or interrupted runs
- Offsite copy completion
- Restore-test date
Add these checks to the same monitoring you use for services. Our Uptime Kuma guide can watch the backup endpoint or status page.
Test restores regularly
A backup is only proven when data comes back. Test at two levels.
First, list snapshots and restore a single file:
restic snapshots
restic restore latest --target /tmp/restore-test --include /home/ubuntu/services/app/compose.yaml
diff /home/ubuntu/services/app/compose.yaml /tmp/restore-test/home/ubuntu/services/app/compose.yaml
Second, perform a service-level recovery drill: restore the database dump and volumes into an isolated directory or test host, start the service, and verify login, files, and recent records. Do this quarterly for important services and after any architecture change.
Document the exact restore commands. During an incident, nobody should have to reconstruct the procedure from memory.
Encrypt and protect secrets
Restic encrypts snapshot contents, but the repository password, remote credentials, SSH keys, and backup scripts still need protection. Restrict file permissions, avoid committing secrets to Git, and separate backup credentials from daily-use accounts.
Keep an offline recovery sheet with repository locations, passwords, encryption keys, DNS details, and service startup order. Store it somewhere accessible even if the homelab itself is down.
Common mistakes
- Backing up containers instead of data
- Only one copy on the same disk
- No database dumps for stateful apps
- Unlimited retention until the disk fills
- Silent cron failures with no alert
- Never testing a restore
- Losing the repository password
FAQ
Can I back up running Docker volumes directly? Often yes for files, but use database-native dumps for databases. Copying live database files without a consistent export can produce unrestorable snapshots.
Should I stop containers during backup? Stop or pause only when the application requires consistency. Otherwise prefer dumps plus volume snapshots, scheduled during low activity.
Local disk or cloud storage? Use both if possible: local storage for fast recovery and an offsite backend for disasters. At least two copies on different failure domains.
How often should I test restores? Verify snapshots after setup, restore individual files monthly, and run a full service recovery drill quarterly for critical data.
Is RAID a backup? No. RAID protects against certain disk failures, not deletion, corruption, ransomware, configuration mistakes, or site-level disasters.
Restic makes the mechanics easy. The real backup system is the routine around it: inventory, encryption, automation, offsite copies, retention, monitoring, and regular restore tests. Build that routine once, and every future homelab service becomes safer to run.