---
title: "Comment by Mike Dabydeen on \"A backup you've never restored is just a rumour\" | Hashnode"
description: "Comparing the scratch counts against the live database will drift on any table that is written constantly. By the time the restore finishes, production has move"
url: "https://hashnode.com/posts/a-backup-you-ve-never-restored-is-just-a-rumour/6ae115f5a868d799e26cc140/comment/6ae1db81ae89b7ba021c5378"
---

[Discussion](https://hashnode.com/posts/a-backup-you-ve-never-restored-is-just-a-rumour/6ae115f5a868d799e26cc140)

Comment [A backup you've never restored is just a rumour](https://hashnode.com/posts/a-backup-you-ve-never-restored-is-just-a-rumour/6ae115f5a868d799e26cc140)

[Mike Dabydeen](https://hashnode.com/@firelinks)

[Oct 28](https://hashnode.com/posts/a-backup-you-ve-never-restored-is-just-a-rumour/6ae115f5a868d799e26cc140/comment/6ae1db81ae89b7ba021c5378)

Comparing the scratch counts against the live database will drift on any table that is written constantly. By the time the restore finishes, production has moved on, so the cron check either complains every night or gets a tolerance wide enough to hide a table that came back half empty.

I'd take the expected numbers from the same snapshot the dump used. Open a session, start a REPEATABLE READ transaction, call pg\_export\_snapshot(), run pg\_dump --snapshot with that name, and run your row counts and newest timestamp in the same session before you commit. Save them next to the dump so they travel to R2 with it. The restore check then compares against exact figures, and any difference is real.

I'd also add --exit-on-error to the pg\_restore line. By default pg\_restore keeps going after an error and only prints a count at the end, which a script that reads row counts can miss.
