-
Notifications
You must be signed in to change notification settings - Fork 0
Role Backup
Configures the automated backup system that creates LVM snapshots of Docker persistent data.
- Installs
wakeonlan - Creates backup directory structure (
/mnt/backup,/mnt/backup/snapshot,/mnt/backup/remote) - Deploys
backup.shandrestore.shscripts to/config
⚠️ The backup directory structure needs cleaning up after recent changes — see the Roadmap.
- Creates a daily cron job at 04:00 UTC
The goal is to back up all Docker container persistent data with minimal downtime. The approach uses LVM snapshots:
flowchart LR
A[04:00 UTC] --> B[Stop containers<br/>~seconds]
B --> C[Create LVM snapshot]
C --> D[Restart containers<br/>back online]
D --> E[Compress snapshot<br/>runs in background]
E --> F[Cleanup]
Container downtime is only the few seconds it takes to create the LVM snapshot. The actual tar/compress operation runs against the snapshot mount, not the live filesystem.
| Step | Action |
|---|---|
| 1 | Stop all Docker containers |
| 2 | Create LVM snapshot of ubuntu-vg/ubuntu-lv (100G snapshot size) |
| 3 | Restart all containers |
| 4 | Mount the snapshot to /mnt/backup/snapshot
|
| 5 | Tar and gzip /docker from the snapshot → /mnt/storage/backups/nas/NAS-Backup.tar.gz
|
| 6 | Unmount and remove the snapshot |
| Variable | Value | Purpose |
|---|---|---|
| LVM Volume Group | ubuntu-vg |
The VG containing the root LV |
| LVM Logical Volume | ubuntu-lv |
The LV to snapshot |
| Snapshot Size | 100G |
Space allocated for snapshot COW data |
| Backup Destination | /mnt/storage/backups/nas |
Where the tar.gz lands |
| Backup Source | /docker |
What gets backed up (from within the snapshot) |
The restore.sh script handles extracting the backup. See the script at playbooks/roles/owendemooy.nas-backup/files/restore.sh for the current implementation.
| Data | Method |
|---|---|
Docker volumes / persistent data (/docker) |
LVM snapshot backup (this role) + Crashplan offsite |
Important storage content (/mnt/storage) |
Crashplan offsite |
| OS configuration, packages, users | Rebuilt from code (Ansible) |
| Docker container definitions | Rebuilt from code (nas-containers-as-code) |
| Secrets | Azure KeyVault (never backed up locally) |
💡 The philosophy is: code rebuilds the structure, backups restore the state. If the NAS dies, you provision a new one from the repos, then restore the backup to get your data back.
In addition to the local LVM snapshot backup, I run a Crashplan container (managed in nas-containers-as-code) to provide offsite cloud backup of content I care about. This covers:
-
/mnt/storage— important files from the MergerFS pool (media, documents, photos) -
/mnt/storage/backups/nas— Compressed copy of LVM Snapshot Docker persistent data (container configs, databases, etc.)
This protects against catastrophic failure scenarios (fire, theft, multiple disk failure) where local backups wouldn't survive. The LVM snapshot handles quick day-to-day recovery; SnapRAID handles disk failures, and Crashplan handles the "house burned down" scenario.
0 4 * * * /config/backup.sh |& tee /tmp/backup.log
Runs daily at 04:00 UTC. Output is captured to /tmp/backup.log for debugging.
🔗 LVM snapshots | MergerFS + snapshots considerations | Crashplan
Overview
Secrets & Networking
Ansible
- Ansible Structure
- Role: Docker
- Role: Storage
- Role: Samba
- Role: NUT Client
- Role: Backup
- Role: Coral TPU
Pipelines
Operations