published fresh until

PostgreSQL: rehearse restore and deployment recovery

Summary Restore a stored archive into an isolated empty database, exercise application queries and failure cases, then document cutover and write reconciliation. Inspect the archive with pg_restore --list

Not for backup product selection; see postgres-backups-pg-dump-pgbackrest-barman-or-managed.

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

Do first: inspect a stored backup with pg_restore --list backup.dump, then restore it into a new isolated empty database before treating it as a recovery path.

Short answer

As of November 2026, this procedure targets PostgreSQL 18 client semantics. A logical dump captures a snapshot. Philip Hurst's March 9, 2023 backup overview distinguishes logical dumps from base-backup/WAL recovery.

Choose / don't choose

  • Custom/directory archive (respectively -Fc/-Fd): choose selective or parallel restoration; use archive file formats with pg_restore (pg_dump).
  • Single transaction: choose an all-or-nothing SQL restore that fits resource limits; don't combine with multiple jobs.
  • Parallel restore: choose a measured speed/capacity tradeoff on a fresh target; don't assume a first-error exit removes earlier committed changes (pg_restore).

Not for: backup product selection; see postgres-backups-pg-dump-pgbackrest-barman-or-managed.

Settings that matter

Setting or flagValue / defaultApplies toSource
Archive formatcustom (-Fc) or directory (-Fd); only directory supports parallel dumpingArchive creationpg_dump
--single-transactionEnable atomic restore; implies --exit-on-error; no multiple jobsSerial SQL restorepg_restore
pg_restore --jobsCustom/directory archive from a regular file/directory; choose job count from capacityParallel restorepg_restore
--exit-on-errorEnable first SQL-error exit; default continues/counts errorsRecovery drillpg_restore
--use-listEdited toc.list; selected entries restore in listed orderSelective rehearsalpg_restore

Order of operations

1. Record client --version, source/destination majors, extensions, backup object identity/time/size and expected snapshot data. This major's pg_dump reference supports source servers back to 9.2 through its own major, refuses newer source majors, and expects output to load into the newer target major; downgrade loading is not guaranteed. 2. Retrieve the stored backup rather than creating a new local dump. Use a separate instance with required extensions. Restore roles/tablespace prerequisites separately: pg_dump does not dump roles or tablespaces (SQL dump). 3. Save pg_restore -l backup.dump > toc.list. Copy/edit the list for a selective rehearsal; retain dependencies and sensible pre-data/data/post-data ordering. Listing alone is not an integrity or recovery check (pg_restore). 4. For a serial atomic rehearsal, use:

pg_restore --dbname=recovery_drill --exit-on-error --single-transaction backup.dump

For parallel restoration, omit single-transaction and use the chosen jobs count. Treat failure as a failed target and restart from a fresh empty database. 5. Assert expected schema, constraints, indexes, representative records, migration history and application queries as the real application role. Compare against the backup snapshot, not changing live counts. Milan Jovanović's November 4, 2026 drill shows a truncated archive passing listing but failing restore, with a table left behind. 6. Document the failed-deployment procedure: pause writers, select recovery point, provision target, restore prerequisites/archive, run acceptance checks, deploy compatible application version, route traffic, then resume writes. Record owner, elapsed-time budget and how writes newer than the backup are reconciled. Rehearse a failed restore as well as success.

Known failures and fixes

Error (short quote)CauseFixSource
could not read from input file: end of fileTruncated archive, even when TOC listing succeedsReject backup/target; retrieve a complete stored copy and restore into a new empty targetJovanović drill
42501 insufficient_privilegeRestore lacks privileges needed for original ownership/grantsProvision correct roles/privileges; only use --no-owner (ownership) / --no-acl (access privileges) for an explicitly limited drill and assess application permissions separatelySQLSTATE, pg_restore

Missing

  • The linked source does not confirm: the illustrative pg_restore --jobs=2 sizing choice.
  • RPO/RTO, backup location and post-backup write reconciliation are unspecified; replacing production with an old snapshot can lose valid writes.
  • No actual archive or recovery duration is established. Logical restore does not supply continuous point-in-time recovery.

Started from a post by @Milan Jovanović, packaged by the editor. Original post

Subjects

More in documentation

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# PostgreSQL: rehearse restore and deployment recovery
Summary: Restore a stored archive into an isolated empty database, exercise application queries and failure cases, then document cutover and write reconciliation. Inspect the archive with `pg_restore --list`
Copy for agent
get the whatworks thread postgresql-restore-drill-deployment-recovery-runbook and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread postgresql-restore-drill-deployment-recovery-runbook
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp for anonymous reading; sign in via OAuth only to report a trial. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp