Infrastructure & continuity
Rehearse PostgreSQL recovery until the application is usable
A backup job finishing tells you that an artifact was produced. A recovery rehearsal should show which business state can be recovered, who can use it and how long that takes. Define those acceptance checks before restoring anything.
Start by choosing the interruption you want the exercise to represent. Losing one database, losing a server and recovering from an unwanted business change can require different procedures. This evergreen guide uses PostgreSQL 18 documentation to define a logical-restore rehearsal. It does not report a test on a KIURO or customer system.
Define recovery in terms the business can accept
Ask the service owner to state two limits: how much recent work may be missing, and how long the application may remain unavailable. These are the recovery point and recovery time objectives. They are targets to test, not achievements implied by a configured backup interval.
Choose evidence that makes those limits observable. The file’s modification time is not automatically the timestamp of the newest recoverable business record. Likewise, the restore process ending is not the same moment that a user can complete the essential task.
| Question | Evidence to collect | Who accepts it |
|---|---|---|
| What backup was used? | Trusted origin, artifact identifier, creation procedure and integrity check | Database operator |
| What work was recovered? | Timestamp/reference of the newest expected business state and checks for important earlier records | Application or data owner |
| When was the service usable? | Exercise start, restore completion and successful application acceptance time | Service owner |
| What remains outside the database? | Required files, configuration, secrets, keys and external-system dependencies | Named technical owners |
Choose a restore path that matches the artifact
A per-database pg_dump does not include cluster-wide roles or tablespaces. Plain SQL dumps are restored with psql; non-text archives use pg_restore. Capture those prerequisites separately rather than assuming that one database file contains the whole operating environment. (PostgreSQL Global Development Group)
Before the exercise, identify the source and destination server versions, necessary extensions, ownership and permissions. Record which global objects must already exist and which are intentionally different in the isolated target. The application should connect as its intended role for acceptance, rather than relying on an operator’s powerful account to conceal missing grants.
A logical dump is not a point-in-time recovery strategy. PostgreSQL documents continuous archiving as a base-backup and WAL-replay procedure; pg_dump output does not contain the information needed for that replay. If the agreed recovery point needs PITR, design and rehearse that separate backup strategy. (PostgreSQL Global Development Group)
Build the isolation before starting the recovered application
Use a disposable destination whose separation from production has been checked. The exercise must not turn a recovered queue into real emails, payments, webhooks or scheduled customer actions. Decide how outbound connections, credentials and background workers will be contained before the application starts.
- Use an authorised backup from a trusted source and restrict access to the recovered data.
- Verify the target identity explicitly; do not rely on a familiar default database name or saved connection.
- Arrange sufficient storage and capacity for both restore work and application checks.
- Prepare safe substitutes or disabled paths for external effects, with an owner for each dependency.
- Define what happens if the restore is incomplete, the target is wrong or the exercise cannot remain isolated.
The restore documentation warns that a dump can execute code selected by the source’s superusers. It also documents that pg_restore --single-transaction implies --exit-on-error and cannot be combined with parallel jobs. Trust, error handling and performance choices therefore need deliberate review; they are not interchangeable safety guarantees. (PostgreSQL Global Development Group)
This article provides no production restore command and no automatic --clean procedure. Select options for the chosen artifact and test destination, and inspect a source you do not trust before restoring it. A successful transaction can still leave an application without its required files or operating configuration.
Accept data, permissions and the user journey separately
Use a short set of business invariants rather than accepting only a row count. In a hypothetical order system, check that an agreed order can be found, its lines refer to the expected order, and its status is internally consistent. Those are proposed checks; no order database was restored or measured for this article.
| Layer | Example check | Reason to hold acceptance |
|---|---|---|
| Database objects | Required tables, extensions and ownership are present | A prerequisite failed or the restore log contains unresolved errors |
| Business state | Selected records and agreed relationships match the recovery target | Missing or inconsistent business records |
| Application access | The intended application role can perform a representative safe read | The application works only under an administrator account |
| Service operation | An authorised tester completes the essential journey with external effects contained | A key dependency is missing or the journey would contact live services |
Keep failures in the report even if a later attempt succeeds. Record what changed between attempts and which backup was used each time. Otherwise an apparently short recovery time may omit the investigation, prerequisite repair or second restore that made the result usable.
Turn the exercise into an operating decision
PostgreSQL’s permissive license allows use subject to its notice conditions. It does not remove storage, infrastructure or operating expenses. (PostgreSQL Global Development Group)
Budget for the isolated environment, retained copies, access control and staff time, then compare the observed result with the service owner’s targets. A passing exercise supports that tested procedure and scenario; it is not a guarantee for every future failure or a substitute for monitoring backup creation.
The next step is a written rehearsal scope: trusted artifact, isolated target, business acceptance checks, evidence timestamps and named decision-maker. If ongoing technical care covers this work, agree its cadence and responsibility explicitly. Keep the result as “not yet demonstrated” until the recovered application has passed the agreed checks.
Sources
- PostgreSQL 18: SQL Dump — PostgreSQL Global Development Group
- PostgreSQL 18: pg_restore — PostgreSQL Global Development Group
- PostgreSQL License — PostgreSQL Global Development Group
- PostgreSQL 18: Continuous Archiving and PITR — PostgreSQL Global Development Group