Opens in a new tab
Guide

Timing a PostgreSQL restore all the way to checkout

In brief

Time a PostgreSQL recovery drill from service disruption to the first verified customer write. Use a missing WAL segment to learn which recovery point you can defend.

4 min read

Is this the right starting point?
Before you read
Familiarity with database backups, application writes and incident recovery.
What you will take away
Choose a verified recovery point and time a restore through the first safe customer transaction.
Sources
A gap separates two strips of film above a backlit splicer. A stopwatch sits beside them.
On this page3 sections

The restore screen says Done. The engineer who has to reopen checkout still has two questions. Which orders did we bring back? If a customer retries the payment from ten minutes ago, will we charge them again?

In this fictional exercise, a maintenance job damaged an orders database at 02:16 UTC. The service owner wants to restore to just before the change. A base backup completed at midnight, the archive shows recent activity, and the team has a forty-five-minute recovery target. There is plenty to do before anyone can tell customers their orders are safe.

Which orders survived the restore?

PostgreSQL point-in-time recovery (PITR) starts from a suitable base backup and replays records in the write-ahead log, or WAL. Those records describe changes to the database. You need a continuous sequence from the start of that backup through the recovery target. A healthy file listing near 02:16 can coexist with a gap at 01:52. Later segments cannot fill the gap.

Give the drill a known-good order committed before the target and a deliberately bad change committed after it. Record both in the exercise plan, along with the intended timeline and the target's UTC time and inclusion rule. On the restored copy, find the good order and verify that the bad change is absent. If you've recovered the cluster before, confirm which timeline you need. PostgreSQL uses timelines to distinguish histories that diverge after recovery. Two histories can pass through the same wall-clock time.

Now run the exercise with the 01:52 segment missing from the exercise copy. Preserve the original archive. The expected outcome is that the team identifies the gap, reports the requested target as unavailable from that copy, and checks whether an independently verified copy can supply it. If the team can verify an earlier recovery point, state exactly which one was tested. A segment timestamp on a dashboard is too weak to validate a business transaction.

Nineteen minutes between database startup and a working checkout

Set the start boundary before the drill. Here, the clock starts at simulated service disruption, at 02:16, because the service objective includes detection and the decision to restore. Run the exercise in isolation with separate identities and outbound integrations disabled or stubbed. Use synthetic order identifiers and a test payment service. Keep the database engine, operator permissions, and verification steps close enough to the production recovery path to expose real dependencies.

For this timed run, the team retrieved the missing segment from a verified second archive and replayed through the intended target.

Evidence from the fictional drillUTC
Simulated disruption02:16
Restore decision accepted02:25
PostgreSQL accepts connections02:45
First order passes the customer-path checks03:04

The engine came back in 29 minutes. Usable checkout took 48, three minutes past the exercise target. Between those two events, the application team looked up an existing order, submitted a new one and repeated the same synthetic payment request with the original idempotency key. The payment stub recorded one charge. A fulfillment event matched the order ID and appeared once in the downstream consumer. Record the expected result and owner for each check before you run it.

The database accepted connections after 29 minutes. Checkout verification finished after 48 minutes, including 19 minutes after database startup.
The drill clock includes time to detect the disruption, choose recovery and verify a customer order.

Recovery point and recovery time tell different parts of this story. The former describes the data state you recovered and how far that leaves you from the disruption. The latter describes how long it took to restore the customer path under a defined clock. State the actual recovery target reached, then reconcile known transactions at the boundary. A billing event can have reached a provider while the matching application record falls in the portion of history you restored away.

Who can reopen writes?

Write down the missing segment, the alternate archive owner, the latest verified transaction, and who can accept any remaining data loss. Give the application owner a deliberate gate before reopening writes. If payment reconciliation is still running, say which traffic can safely reopen and which must keep waiting.

In the exercise, the most valuable follow-up comes from those final nineteen minutes. If twelve were spent finding someone with permission to run reconciliation, faster storage won't move the number that customers felt. Fix the handoff, rehearse with the same start and end boundaries, and see what it buys.

Sources

Sources & context

Sources linked in this article. Read alongside the author’s analysis; a citation does not independently verify a publisher’s claims.

Report an error or outdated detail

Keep reading

Where to go next