Skip to content

Lesson 10 of 13 · 14m

You Can't Restore What You Never Backed Up

IaC rebuilds compute, not state; the backup inventory comes from a rebuild drill on a blank VM, not from memory.

Restores fail on the thing nobody wrote down. The database was backed up; the TLS private key was not. The app deploys cleanly; the DNS zone export never existed. The inventory problem is that state hides in places that feel like configuration — and configuration is exactly what nobody backs up because "it's all in git."

The IaC blind spot

The wrong mental model is: everything is Terraform/Ansible/git, we rebuild from source. IaC rebuilds compute — packages, topology, service definitions. It does not rebuild state, and state lives precisely where the disk died. Walk a real host and count what is stateful-but-not-code:

  • /etc on the pet VM that predates the Terraform — nginx confs hand-tuned in 2021, cron entries somebody added at a shell prompt, the sshd_config with the port everyone forgot.
  • TLS private keys and ACME account keys. Lose the host keys too and every SSH client screams REMOTE HOST IDENTIFICATION HAS CHANGED at your customers on day one of the rebuild.
  • The DNS zone itself. Managed DNS lives in the provider, not your repo — until the provider account is the thing that died. Zone exports (Route53, Cloudflare API, dig axfr where it's allowed) are a backup.
  • Secrets stores: Vault's Raft data, etcd snapshots (etcdctl snapshot save), SOPS-age key files. Encrypted, sure — and still data that can be deleted. An age key file lost with the host turns every SOPS-encrypted secret in the repo into ciphertext confetti forever.
  • Terraform state: it's an inventory of the real world plus cleartext secrets. Lose it and your infra is orphaned resources that terraform plan has never heard of.
  • CI secrets and deployment credentials living only in a SaaS console.
  • GitHub itself: git clone covers code. Issues, PRs, reviews, repo settings, branch protections, Actions secrets, releases metadata — none of that is in the repo. gh api exports, git clone --mirror for the refs, scheduled dumps to the same offsite domain as everything else.
  • Monitoring configuration — the alerts that would have told you something was on fire, now gone with the fire.
  • Deployment-side reachability: CI runner registrations, deploy SSH keys, the kubeconfig that lets you reach the cluster you need to rebuild.
  • Third-party consoles: Stripe webhook endpoints and product catalog, Cloudflare rules, email provider settings — the config surface of services you don't run.
  • The .env file and systemd unit overrides (systemctl edit output lives in /etc/systemd/system/<unit>.d/) that never made it into a repo because "it's just one line."
  • The backup-job definitions themselves — the systemd timer, the script holding RESTIC_REPOSITORY and RESTIC_PASSWORD, the repo URLs. Lose the host and you keep the repositories but lose the map to them.
  • Container volume state: docker volume ls is named volumes holding databases and uploads that live outside the compose file.
  • Operator dotfile state nobody imports into IaC: ~/.ssh/authorized_keys on ops boxes, locally installed certs, known_hosts entries that keep automation from stalling on a prompt.
  • License files and activation state on software that won't reinstall cleanly without them.

How the inventory actually gets built

From a drill, not from memory. The empirical method: rebuild the service onto a blank VM from your IaC alone, boot it, and write down everything that is missing or wrong. That list is the backup inventory — generated by the same procedure a real disaster would run. Every item on it gets a named backup path: dumped, exported, replicated, or pulled into the file backup.

Then keep it honest:

  • Quarterly re-run of the rebuild drill; new state creeps in constantly.
  • Every stateful thing names its backup mechanism in the runbook — not "covered by the nightly job," a specific artifact.
  • Third-party config gets an export where an API exists, and a runbook note where it doesn't.
  • The inventory includes where the secrets that unlock the backups live — the list is useless if the repo password only existed on the dead host.
  • And the inventory itself lives offsite: a map stored only on the host it describes burns with the territory.

You cannot restore what you never backed up, and you cannot back up what you never inventoried. The rebuild drill is how you find out which sentence of that pair is currently lying.

Was this lesson helpful?

Sign in to rate

Keep reading

Related articles from the SudoSecurity blog.