All articles

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.

KIURO Editorial · Published: · Reviewed:

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.

Proposed evidence sheet for a rehearsal
QuestionEvidence to collectWho accepts it
What backup was used?Trusted origin, artifact identifier, creation procedure and integrity checkDatabase operator
What work was recovered?Timestamp/reference of the newest expected business state and checks for important earlier recordsApplication or data owner
When was the service usable?Exercise start, restore completion and successful application acceptance timeService owner
What remains outside the database?Required files, configuration, secrets, keys and external-system dependenciesNamed 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.

Proposed acceptance sequence
LayerExample checkReason to hold acceptance
Database objectsRequired tables, extensions and ownership are presentA prerequisite failed or the restore log contains unresolved errors
Business stateSelected records and agreed relationships match the recovery targetMissing or inconsistent business records
Application accessThe intended application role can perform a representative safe readThe application works only under an administrator account
Service operationAn authorised tester completes the essential journey with external effects containedA 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

Privacy & analytics

With your permission, Kiuro uses Google Analytics 4 to understand page visits and interactions such as navigation between pages, reading depth, project views, contact-link clicks and starting or successfully submitting a form. Google also processes browser, device and approximate location information. The provider is Google Ireland Limited (Ireland); processing may also take place at Google LLC in the United States.

We do not send your name, email address or message content. Advertising storage, advertising personalisation and Google signals are disabled. Google Analytics is not loaded before you allow it.

After consent, a temporary record in this tab is valid for 30 seconds and consumed when the next page loads. Your choice is saved on this browser for six months. Analytics cookies are configured to expire after six months. You can change your choice here at any time; rejecting stops measurement and removes this website’s Analytics cookies.

Your light/dark and motion preferences are stored separately on this device so the interface remembers your choices. Contact: hello@kiuro.ch.