A restored dump can differ from the live database because a write landed after the dump took its snapshot. How can you tell when a difference needs investigation? Our earlier article, “A Backup Isn’t Recovery Until You’ve Restored It”, covered checksums and a basic restore drill. This one is about the live-write problem that drill leaves open.
The question is this: when a backup is taken from a database that is still being written to, how do we tell a correct backup from a damaged one, and what do we say when we cannot tell?
The work described here was done in disposable test containers on small synthetic data. It is a design we tested in those containers. The engineering record dated 22 November 2026 says this check had not been applied to the founder trial’s live backup job. It was designed and run with AI assistance and has not been independently validated. The limits below are part of the result.
Which snapshot did the verifier see?
PostgreSQL’s pg_dump reads from a consistent snapshot even while other sessions write to the database. PostgreSQL also lets a dump and a verification session use the same exported snapshot. We measured that option in a disposable test. The check described here used separate before and after captures. Comparing those captures with the restore cannot establish that the verifier saw the dump’s exact snapshot.
PostgreSQL’s pg_verifybackup checks a physical base backup produced by pg_basebackup against its manifest. Logical pg_dump archives fall outside its scope. The documentation also recommends test restores and checking the recovered data.
Bracket the dump with two fingerprints
The approach we tested takes a content fingerprint of the database immediately before the dump and another immediately after. A fingerprint here is a set of hashes, one per table, captured together in a read-only transaction. The dump is then restored into a throwaway database, which is fingerprinted the same way. The restored copy is compared with the before and after fingerprints, never with a second dump.
The comparison is made table by table. If every table in the restored copy equals its before fingerprint or its after fingerprint, nothing in the check contradicts the dump. This is a per-table diagnostic, not proof that the whole restored database equals one complete before or after state: different tables may match different ends of the window. If a table differs from both, the check has to decide whether the difference is explained by writes that happened inside the window or looks like damage.
Four verdicts, and never a silent clean
| Verdict | Observation | Interpretation |
|---|---|---|
| Clean | Every checked table matches both endpoints. | All three observed fingerprints agree. An intervening write that was reversed can leave matching endpoints. |
| Window write | Every checked table matches at least one endpoint, and at least one table matches only one. | The observed change is consistent with a write during the window. Different tables may match different ends. |
| Indeterminate | A table matches neither endpoint, and the differing rows are accounted for by the window. | The table remains unverified. In the tested configuration the check passes with a status note and no alert. |
| Corrupt | The comparison finds a difference the window cannot explain. | The check fails. This verdict can also occur for a valid dump. |
The indeterminate verdict exists because an earlier build of the check, in these same tests, raised a false corruption alarm when a table was written both before and after the dump snapshot: the dump then legitimately matched neither fingerprint. Comparing per-row hashes lets the check excuse a difference only when every changed row is accounted for by the window, and it is deliberately conservative about what counts as accounted for. An indeterminate result is never presented as clean. Corrupt is the check’s classification of a difference it cannot explain, not proof that data was damaged: the false alarms described below also land there.
What we tested
We ran the check in disposable containers with no network access, on a small synthetic dataset. The backup step was a stand-in for the real backup script, and writes were scripted single statements, not concurrent load. The cases and results, as reported by the engineering test harness, were:
- A quiet database produced a clean verdict.
- A single write on either side of the dump snapshot produced a window-write verdict and the restore check still passed.
- Writes on both sides of the snapshot to the same row produced an indeterminate verdict instead of the false alarm an earlier build raised.
- Damage injected into each of seven classes of stored data was classified as corrupt in a quiet window, and also when concurrent writes were present, provided the damage was on rows those writes did not touch.
- If the check itself crashed, hung or was missing, the backup was still taken and an alert was raised, in the advisory mode we tested.
These are results from a test harness that we describe, not independent measurements. The check was designed and run with AI assistance and has not been independently validated. The behaviour was exercised on one clean harness run; an earlier run was discarded because a second launch shared its scratch directory.
What the check does not establish
The most important limit is a blind spot we found and kept. If damage lands on a row that was also written inside the window, the difference looks like a legitimate window write and the verdict is indeterminate. It is never reported as clean, but it is not detected either: in the tested configuration an indeterminate result passes the restore check with a status note and no alert, so such damage would not raise an alarm. It stays unproven: a later quiet-window backup can verify that later backup, but it cannot retroactively verify the earlier dump. Damage applied to the live database inside the window is likewise indistinguishable from a legitimate write.
Other limits follow from how the check works. A row inserted and then deleted inside the window is still classified as corrupt, which is a false alarm, so a corrupt verdict is a verifier classification and not proof of damage. Tables without an identifier column, and databases above a configured size, fall back to a simpler, more conservative table-level rule. Damage was injected by dumping a damaged copy of the database, not by flipping bits in a stored file, because a flipped bit would fail the checksum before this comparison ran. The evidence log the check writes is local and sits beside the fingerprints it vouches for, so it is not tamper-evident and is not stored off the machine.
We measured no behaviour at realistic data volumes or under concurrent load. In small, unloaded observations on that dataset (three runs, in-memory storage, illustrative only) the extra capture work added roughly two seconds to the backup and about one second to the restore check; we make no claim that this scales.
What this verification establishes
On small synthetic data in disposable containers, comparing a restored dump with fingerprints taken before and after the dump separated clean, window-affected and damaged outcomes. It avoided calling one class of legitimate concurrent write, the same row changed on both sides of the snapshot, corruption; a row inserted and deleted inside the window still raises a false alarm. It also reported what it could not decide rather than rounding that up to clean.
It does not establish that a live memory store would be protected from loss, that the approach is new, or that it works at scale. We did not run a full literature search and do not claim this approach is new; similar ideas may already exist. What we can report is an engineering check on a memory store, tested on synthetic data, with its limits stated.
A restored backup that matches is good evidence. A restore check that can say “I cannot tell” is better evidence than one that always answers.
← All engineering articles