I was building and testing a PostgreSQL backup and restore workflow using pgBackRest.
The idea was simple:
take backups
restore them automatically
validate the database
make recovery predictable
Instead, I ended up repeatedly breaking PostgreSQL recovery itself.
At one point, PostgreSQL refused to start entirely, the application depending on it failed to start, and I started seeing errors like:
invalid checkpoint record could not locate a valid checkpoint record at 0/DEAD
Enter fullscreen mode
Exit fullscreen mode
Later, I also hit timeline mismatch errors like:
ERROR: [058]: target timeline 3 forked from backup timeline 2
Enter fullscreen mode
Exit fullscreen mode
At first, I thought:
pgBackRest restores were corrupting PostgreSQL.
That assumption turned out to be completely wrong.
The real problem was the way I was handling recovery.
What I Was Building
I was testing a PostgreSQL backup/restore flow locally after repeated restore failures elsewhere.
To isolate the issue properly, I…