Skip to content

ADR 006

Backups and rebuild

Git and Terraform rebuild configuration. Every other kind of data gets one backup method, a maximum age and a tested restore. Only data that can't be replaced goes offsite.

Status
Accepted
Rollout
0 of 7 gates
Related

Accepted, not yet implemented.

Context

Git and Terraform recreate configuration and virtual machines. Neither restores etcd, databases, volumes or secrets. Each of those has its own consistency and restore rules, so one backup tool can't protect them all safely.

The disaster this ADR plans for is cluster loss: every Talos VM and every Longhorn volume is unusable, while Proxmox, the network, TrueNAS, Bitwarden and the cloud services still work. Site loss has no recovery time target, but an offsite copy of all irreplaceable data must survive it. Data that can be downloaded again or regenerated may be lost with the site. Backups containing secret values must be encrypted. Losing the site and the GitHub account together is accepted. That case gets a slow, manual rebuild.

TrueNAS also holds the household's personal files, and its Cloud Sync tasks copy them to B2. B2 bills $6.95 per TB per month, including hidden and old file versions. In October 2026 the bill reached $17. In November the account held 2.0 TB: 1.6 TB of current files and 0.4 TB of old versions, most of it one large folder that moved inside a synced share. The budget for the NAS buckets is about $10 a month.

One operator runs the platform. A recovery path nobody runs goes stale, so recovery uses the same code path as a normal bootstrap, and every path gets a first test and a place in a yearly drill.

Decision

What is backed up

Each data type has one backup method and one freshness limit:

Data Backup Max age Retention Restore Status
Git repos Docker-host job writes a bare repo and dated bundles to TrueNAS over NFS; the existing TrueNAS job copies them to B2 without encryption 24 hours Newest bundle of 30 dates with bundles, first bundle of 12 months with bundles Clone, or point Flux at the Docker host Runs daily, restore tested
Terraform state GCS versioning and soft delete, plus a daily age-encrypted copy to B2 when the serial changed 24 hours Latest copy kept indefinitely, older copies 90 days Pick a generation, or decrypt the copy Not automated
etcd Talos snapshot CronJob, age-encrypted, to B2 6 hours 30 days Only for control-plane failures. Rebuild from Git is the default. Manual only
OpenBao Raft snapshot, age-encrypted, to B2. Also after important key changes. 24 hours 30 days bao operator raft snapshot restore Manual only
Longhorn volumes Longhorn backup to B2 24 hours 7 daily, 4 weekly Restore while apps are suspended Not implemented
Postgres CNPG Barman to B2 Continuous WAL, daily base 14 days CNPG recovery bootstrap Not implemented
NAS personal files, irreplaceable class TrueNAS Cloud Sync to B2 with TrueNAS remote encryption 24 hours, 8 days for the weekly photo task Current files, old versions 30 days Download and decrypt with rclone, using the task's crypt settings Runs, restore not tested

Container images are not backed up. CI rebuilds them from source.

ADR 010 covers the Terraform state backend and its daily B2 copy.

Longhorn and CNPG write directly to their own B2 stores, and their controllers own retention. Don't copy those stores through TrueNAS, and don't apply B2 lifecycle rules to them. B2 is the only backup layer for cluster data. The owner rejected a TrueNAS tier in front of it on 2026-12-04, so one restore path needs maintaining and testing.

Proxmox does not back up the Talos VM disks. A disk image of one Talos node is not a way to recover the cluster, and the rows above already cover the data on it. Recurring Longhorn snapshots inside the cluster give quick rollback (ADR 008). They are not backups.

The etcd snapshot job runs in Kubernetes with the os:etcd:backup Talos role. It gets only a B2 write credential and the public age recipients. Restores use a separate B2 read credential and an age identity kept outside Kubernetes.

Velero is not installed. Talos, Git, Longhorn, CNPG and OpenBao already cover every data type. Reconsider it only when a workload has Kubernetes resources or mounted files that none of them cover.

NAS file data

TrueNAS file shares hold two classes of data. ZFS snapshots protect both on site and keep at least 30 days. Only the irreplaceable class goes to B2. The NAS buckets are the B2 buckets that TrueNAS Cloud Sync tasks write to, including the Git bundle bucket.

Class Examples Offsite
Irreplaceable Documents, accounting, photos and videos, Immich originals and its database dump, project work that exists nowhere else, game saves and server worlds, Git bundles TrueNAS Cloud Sync to B2
Replaceable Installers, plugin and sample archives the vendor still offers, AI model weights, game installs, Immich thumbnails and transcoded video, verified copies of data that another task sends offsite None. Lost with the site.

Data is replaceable only when the owner has confirmed it can be downloaded or rebuilt again. When a folder's class is unclear, it is irreplaceable. Exclude the narrowest path. In a folder that holds both classes, such as a portable application with its outputs, exclude only the replaceable subfolders.

Don't send whole WSL or virtual machine disk images offsite. Move the files in them that exist nowhere else into Git or an irreplaceable folder first, then exclude the image. Until then the image is the only offsite copy of those files.

The Cloud Sync tasks on personal datasets list what to exclude, not what to include. A new folder goes offsite until someone marks it replaceable. A forgotten exclusion costs a few dollars and shows on the bill. A forgotten inclusion loses data and shows only after the site is gone. Classify and size every existing top-level folder and file before switching a task to an exclude list.

A new exclusion does not remove the folder from B2. rclone skips an excluded path on both sides, so sync neither uploads it nor deletes the copy already in the bucket. When adding an exclusion, delete that folder from the bucket once. Delete it with rclone and the task's crypt settings, not in the B2 web UI, which shows encrypted names when filename encryption is on. rclone only hides the files, and the lifecycle rule removes them 30 days later, so the bill drops a month after the cleanup.

The Cloud Sync tasks run in SYNC mode. When a file is deleted or changed on the NAS, B2 keeps the old version and bills it until a lifecycle rule removes it. Each NAS bucket deletes a version 30 days after it stops being current and cancels unfinished large uploads after 7 days. Those 30 days cover a mistaken delete or a sync of ransomware-encrypted files that someone notices within a month. ZFS snapshots cover the same window on site.

B2 caps are dollars per day, cover the whole account and all its buckets, and block every upload when reached. Backblaze emails at 75% and 100%. Divide the expected monthly bill for the whole account, including the platform stores, by 30 and set the daily storage cap at 1.6 times that. The 75% email then arrives about 20% above the expected bill. Set the cap only after the daily storage charge has dropped below it, and raise it before adding a B2 store or a large new folder. A reached cap fails every backup job. Backblaze's 100% email reports it, and the max-age alerts will too once they exist. If the irreplaceable class alone outgrows the budget, raise the budget. Don't drop irreplaceable data to fit it.

The other platform rows in the backup table keep their own buckets and retention. The NAS budget doesn't cover them.

Git backups

A daily job in a manually deployed Compose stack on the Docker host updates a bare repo and keeps dated bundles for every repo when refs change or no dated bundle remains. Retention keeps the newest bundle of each of the latest 30 dates with bundles and the first bundle of each of the latest 12 months with bundles. It writes to a dedicated TrueNAS dataset over NFS. The Talos installer image for the pinned version sits next to them. ZFS snapshots and the existing TrueNAS to B2 job cover the dataset. Stack files come from scripts/git-backup/. Credentials stay in the stack's ./private bind mount on the Docker host, outside the backup tree. TrueNAS remains a NAS and runs no custom backup or Git-serving code.

The Git dataset's TrueNAS to B2 task intentionally uses no encryption. The owner chose this on 2026-10-27 because the repositories hold no secret values and could be public. This exception does not cover state or secret backups.

The Docker host serves the homelab mirror over read-only SSH. The Flux deploy keys are authorized there, and its host key is in Flux's known hosts. The Flux source URL is a bootstrap input, set where Git reconciliation can't revert it, so a rebuild during a GitHub outage can point Flux at the Docker host. This endpoint needs both the Docker host and NAS. Bundles on B2 remain the fallback if either is lost.

Offsite freshness comes from the success of the TrueNAS to B2 job, not from the Docker host's fetch.

Alerts

Each row in the table has its own last-success signal and its own alert. The alert fires when the max age is exceeded, not after two missed intervals. Two missed intervals would let a daily backup go 48 hours unnoticed. Jobs that run outside the cluster also ping Uptime Kuma (ADR 004).

Default recovery

After cluster loss, rebuild from Git:

  1. Bootstrap the cluster from Git with the applications suspended. The suspension is a bootstrap input.
  2. Restore volumes, databases and OpenBao.
  3. Check the restored data and the matching secrets.
  4. Resume the applications.

There is no separate recovery mode and no write-inhibition control. Normal bootstrap and recovery bootstrap are the same path with one input changed.

This needs one suspension boundary that holds every application writer and none of the components needed to restore them. The suspension must hold from the first reconciliation, and Git reconciliation must not undo it.

etcd restores are only for control-plane failures, such as lost etcd quorum with a valid snapshot. They are not the default for full cluster loss.

Restore order

Restore order follows dependencies, not only the value of the data. A service that supplies platform prerequisites restores first, even when its own data is replaceable. The recovery tiers in the glossary don't override that order.

Encryption and recovery credentials

Except for the Git dataset and the NAS file data described above, encrypt every backup artifact directly to the same three age recipients as today: two YubiKeys and the offline key. Each one can decrypt on its own. Backup jobs get only the public recipients, listed in scripts/recovery/backup.recipients.txt, and the age YubiKey plugin. No intermediate backup identity exists, and no private key lives in Kubernetes.

Keep an old identity while retained archives still need it. Changing recipients only affects new artifacts.

Self-hosted Bitwarden holds the normal credentials. The recovery credentials also live in Bitwarden cloud and in one offsite bundle, so recovery works with the lab down. Retire the redundant local recovery copy once offsite recovery is verified on its own.

The offline age key stays disconnected, in secure physical custody, apart from the YubiKeys and every onsite system.

The NAS Cloud Sync tasks use TrueNAS remote encryption, which is rclone crypt with a password and salt instead of age. TrueNAS has no age option. Each encrypted task's password, salt and filename-encryption setting are recovery credentials. They live in Bitwarden cloud and the offsite bundle with the others, because without them the NAS copies in B2 can't be read after site loss.

Tests

Run each of these once on production, before it holds data:

  • A rehearsal: destroy the cluster, then rebuild it from Git with OpenBao restored from a snapshot, one Longhorn volume restore, one CNPG point-in-time restore, and an application write and read. The snapshot comes from the OpenBao that production replaces, which stays the authority until the rehearsal has passed.
  • One etcd snapshot restore.
  • One drill with Garage stopped, including a ruler restart, that confirms a notification arrives.
  • One Flux reconcile from the Docker host's NFS-backed Git copy with GitHub blocked.

Also restore one file from each encrypted NAS Cloud Sync task once, with no onsite system. Download and decrypt it with rclone, using only the offsite copies of the B2 read credential and the task's crypt settings.

The rebuild with OpenBao unreachable runs on staging, which has one node and can be rebuilt at any time.

After that, run one drill a year on a temporary cluster (ADR 002). It rotates through a volume restore, a database restore, an etcd restore and the Docker host's Git source. Volume and database restores can also go into a scratch namespace on production. Each yearly drill also restores one NAS file the same way and checks the largest new folders on the personal datasets against the two classes. Run the rehearsal again on a temporary cluster after any material change to recovery.

Consequences

  • Several small backup jobs instead of one tool. Each one fits the consistency rules of its data.
  • B2, GCS and Bitwarden cloud are production dependencies.
  • Replaceable NAS data is gone after site loss. Getting it back means downloading or rebuilding it.
  • An upload is not proof. A restore test is.
  • No fixed recovery time is promised.
  • The Flux layout has to change before the default recovery works (see below).

Implementation status

The table's Status column shows each backup. The suspension boundary does not exist yet. fdm-monster-staging reconciles on its own (kubernetes/clusters/staging/fdm-monster.yaml). On k3s, OpenBao sits inside the apps tree (apps/production/kustomization.yaml:29 in igresc/gitops), and production Talos must not copy that layout. Phase 3 of the migration builds the boundary and its bootstrap input. Both Talos disks still set backup = true (terraform/modules/talos_vms/main.tf), and no Proxmox backup job includes them. The BackupStale alert runbook exists, but no alert rule does yet. The NAS Cloud Sync tasks still use include lists. They copy some replaceable data and miss some personal folders. The personal-file bucket keeps old versions 90 days and the Git bundle bucket 30. ZFS snapshots on the personal datasets keep 2 weeks, and the photo dataset has none. The daily cap and the offsite copies of the crypt settings are not checked yet.

References

Rollout gates

  • Every row of the backup table runs on a schedule and alerts on its max age. open
  • Each test in the Tests list has passed, plus one restore of a TrueNAS Git bundle and one restore of a B2 Terraform state copy. open
  • The suspension boundary exists, and a staging rebuild with OpenBao unreachable keeps the applications suspended from the first reconciliation. open
  • The rehearsal and the other first tests above have passed. open
  • Recovery credentials can be retrieved and an artifact decrypted using only Bitwarden cloud and the offsite bundle, with no onsite system. open
  • Every top-level folder and file on the personal datasets is classified and sized, the Cloud Sync tasks use exclude lists, and no replaceable data remains among the current files in the NAS buckets. open
  • Every NAS bucket deletes old versions after 30 days, ZFS snapshots on the personal datasets keep at least 30 days, the B2 daily storage cap is set, and one file from each encrypted NAS task is restored with no onsite system. open

docs/decisions/006-layered-disaster-recovery.md