Skip to content

Lesson 1 of 13 · 14m

A Backup Is Not a Restore

A green backup job means a process exited 0; only a completed restore proves a backup exists.

The disk dies at 02:14, or somebody runs rm -rf on the wrong node. What exists after that moment is not what your dashboard shows — it is whatever bytes the last backup job actually wrote. A backup is a writer that runs hundreds of times a year, unattended, at low stakes. A restore is a reader that runs once, under pressure, and has to consume every byte the writer ever produced. Those are different jobs with different failure modes, and only one of them is the product.

The green checkmark is not the product

The mental model that fails is this: the backup job exited 0, therefore we have backups. Exit code zero means the process finished. It says nothing about whether the artifact can be restored — and a job can report success while the tool inside it failed. pg_dump does not exit 0 on a client/server major-version mismatch: it aborts with a fatal version-mismatch error and writes nothing. The wrapper around it can still exit 0 and ship the empty result, which is how a loud tool failure becomes a green checkmark. rsync -a --delete exits 0 after faithfully mirroring your deletion to the backup disk. restic backup exits 0 even when the only path that matters — restore — has never been exercised once.

This is not hypothetical pedantry. On January 31, 2017, a GitLab engineer troubleshooting replication lag ran rm -rf on db2.cluster.gitlab.com — the production primary, not the secondary he thought he was on. Roughly 300 GB of database went away; the command was stopped with about 4.5 GB left. The postmortem GitLab published — publicly, while they livestreamed the recovery — lists the backup and replication mechanisms they believed they had. There were five. None worked:

  • The pg_dump-based backups pushed to S3 were silently empty — the job ran PostgreSQL 9.2's pg_dump against a 9.6 cluster, pg_dump refused the mismatched majors and aborted, and the pipeline shipped the empty results anyway because nothing ever inspected the artifact.
  • Azure disk snapshots were enabled for the NFS server holding git repositories, but not for the database servers.
  • LVM snapshots existed but were stale by the time anyone looked.
  • Replication — the mechanism everyone assumed would cover exactly this event — had already died, which is the thing they were troubleshooting when the rm happened.

About six hours of issues, merge requests, and comments were permanently lost. Git objects survived because they lived on a different server. The failure was not a missing backup layer. It was five backup layers that had never once been restored, each failing in a way that was only visible at restore time.

Redundancy is not backup either

Two adjacent confusions compound the problem. RAID is not a backup: it survives a disk failure and nothing else — the rm, the ransomware, and the fire all see one filesystem. Replication is not a backup: it copies DROP TABLE production.orders to the standby with sub-second latency and excellent consistency. Redundancy keeps you up through hardware failure. Backup is for getting the data back after the damage is done. You need both, and only one of them can rewind time.

What to actually measure

A backup you have never restored is a hypothesis, not a fact. Make the restore the deliverable:

  • Artifact checks, not exit codes. After every run, verify the artifact exists and is non-empty: restic snapshots lists it, pg_restore --list dump.pgc parses its header, sha256sum or stat shows sane bytes. A job that exits 0 while shipping an empty artifact is the canonical silent failure — GitLab shipped exactly that for months.
  • Timed restore drills. Restore to a scratch VM or container, boot the thing, run its own smoke check, and record wall-clock duration. You now know two numbers a dashboard can't give you: how fresh your newest restorable artifact is, and how long recovery actually takes.
  • Alert on drill failure like a failed backup. A restore test that fails at 14:00 on a Tuesday is the cheapest incident you will ever have.

The backup job is instrumentation. The restore is the system. Build for the reader.

Was this lesson helpful?

Sign in to rate

Keep reading

Related articles from the SudoSecurity blog.