Plan for Disaster Recovery
Turn the recovery capabilities of Managed PostgreSQL into a runbook: which path recovers which failure, what each path costs in data and time, the exact command sequence, and how to rehearse before you need any of it.
Three Failures, Three Paths
Managed PostgreSQL gives you three distinct recovery paths, and they are not interchangeable:
| Failure | Recovery path | Relies on |
|---|---|---|
Bad data was written: a dropped table, a migration gone wrong, an UPDATE without a WHERE | Fork the service to a point in time just before the mistake | Base backups and WAL archiving, on every service; forking needs a startup-* plan or larger |
| The zone is unavailable | Promote a read replica running in another zone | A cross-zone replica you created in advance |
| The service was deleted | Restore your own dump into a new service | pg_dump files you keep outside the platform |
Warning
Failover inside a highly available plan (business-*, premium-*) is automatic, and only
automatic. The API exposes no operation to promote a standby, to move the primary role, or to
trigger a failover on demand, so you cannot fail over by hand and you cannot rehearse a failover.
Rehearse disaster recovery with a fork, which is safe to create at any time and never touches
the source service. See
High availability.
Standby nodes also do not cover the zone scenario: all nodes of a service run in the same zone, so an HA plan protects against node loss, not zone loss. Cross-zone redundancy comes from a read replica in a second zone. See Limits and quotas.
What Each Path Costs
No fixed recovery-time number is honest across plans and data sizes, so reason in mechanisms and measure your own values in a drill:
- Fork to a point in time. Base backups are taken on a plan-defined cadence and every WAL segment is archived continuously, so you can land on any moment inside the recovery window: no earlier than the oldest retained base backup, no later than now. Data written after the target you choose is discarded by design, which in the bad-data scenario is the point. Time to recover is the fork creation, then your verification and the application switch: a small service comes up in a few minutes, a large one takes as long as its backup and WAL take to restore. See Backups and point-in-time recovery.
- Promote a replica. You lose whatever replication lag was outstanding when the zone went away. The lag is observable at any time with the queries below: measure it in steady state so you know the data loss this path would cost you today, instead of discovering it during an incident. Recovery time is one promote command plus the application switch.
- Restore your own dump. You lose everything written since the last dump you took: the cadence
of your own
pg_dumpruns is the recovery point of this scenario, and the platform contributes nothing to it. Recovery time is creating a new service plus restoring the dump at full data volume.
Read the backup cadence and retention for the plan you run. On startup-4, for example, the
values are an interval of 24 hours, 3 base backups kept and recovery mode pitr:
exo dbaas type show pg --backup-config PLANParameters:
PLAN: the plan of your service, for examplestartup-4.
Scenario 1: Bad Data Was Written
Fork the service to the last good moment. The source service keeps running, untouched, the whole time, so nothing about this path can make the incident worse.
A service on a hobbyist-* plan cannot be forked. If this scenario matters for a service, run it
on a startup-* plan or larger, or keep your own dumps as in
Scenario 3.
If you can, stop the application component that wrote the bad data, so the incident has a clean end time.
Establish the recovery window:
exo dbaas show my-postgresql -z ch-gva-2 --backupsYou cannot recover to a moment earlier than the oldest backup listed, and not later than now.
Choose the target timestamp: the minute before the incident began. A fork you throw away costs minutes, a fork that lands after the bad write costs the incident.
Create the fork:
exo dbaas create pg PLAN FORK_NAME -z ch-gva-2 \ --pg-fork-from my-postgresql \ --pg-recovery-backup-time TIMESTAMP \ --pg-ip-filter CIDRParameters:
PLAN: plan of the fork, for examplestartup-4.FORK_NAME: name of the new service, for examplemy-postgresql-fork.TIMESTAMP: the ISO 8601 moment to recover to, in UTC, for example2026-08-31T14:31:00Z.CIDR: a network block allowed to connect to the fork, for example203.0.113.0/24.
To target the very start of the window, do not reuse a listed
backup-timeas is: it is truncated to whole seconds and the fork is rejected as out of range. Use a moment at least one second later.Watch it come up, from
rebuildingtorunning:exo dbaas show FORK_NAME -z ch-gva-2Read the fork’s connection URI, connect, and confirm it contains the state you aimed for. The fork has its own hostname, and the same roles and passwords as the source at the recovery point. Its IP filter is the one you passed at creation.
exo dbaas show FORK_NAME -z ch-gva-2 --uriChoose the way back, and make it an explicit step:
Switch over entirely. Repoint the application at the fork’s URI, then treat the fork as the new production service: give it the integrations, IP filter and maintenance window the old one had. None of them is copied by the fork.
Copy the damaged rows back. Keep production on the source service, connect to the fork and copy the correct rows into production, for example with
pg_dump --data-only --tablefrom the fork andpsqlinto the source, then delete the fork:exo dbaas update FORK_NAME -z ch-gva-2 -f --termination-protection=false exo dbaas delete FORK_NAME -z ch-gva-2 -f
Scenario 2: The Zone Is Unavailable
This path only exists if you built it in advance. A replica created after the zone went down has nothing to replicate from.
Prepare, Before Any Incident
Create a read replica in a second zone, with the API as described in
Use read replicas. A
replica needs a startup-* plan or larger.
exo api create-dbaas-service-pg REPLICA_NAME -z REPLICA_ZONE <<EOF
{
"plan": "PLAN",
"ip-filter": ["CIDR"],
"integrations": [
{
"type": "read_replica",
"source-service": "my-postgresql"
}
]
}
EOFParameters:
REPLICA_NAME: name of the replica service, for examplemy-postgresql-replica.REPLICA_ZONE: a zone different from the primary’s, for exampleat-vie-1.PLAN: plan of the replica, for examplestartup-4.CIDR: a network block allowed to connect to the replica. Do not omitip-filter: a replica created without one accepts no connections at all.
Then measure the lag in steady state, because it is the data this path loses. On the primary:
SELECT application_name, client_addr, state, sync_state,
pg_wal_lsn_diff(sent_lsn, replay_lsn) AS replay_bytes
FROM pg_stat_replication
WHERE application_name <> 'pghoard';The filter matters: the pghoard row is the platform’s WAL archiver, not your replica. On the
replica:
SELECT pg_is_in_recovery() AS is_replica,
pg_last_wal_receive_lsn(),
pg_last_wal_replay_lsn(),
now() - pg_last_xact_replay_timestamp() AS replica_lag;How to read the two views together, including the idle-primary case, is covered on Use read replicas.
Recover, When the Zone Goes Down
Confirm what you have. The list command searches every zone and needs no
-z:exo dbaas read-replica list my-postgresqlOn the replica, run the replica-side query above. With the primary unreachable, the last lag values you observed are your estimate of the data lost.
Promote:
exo dbaas read-replica promote REPLICA_NAME -z REPLICA_ZONE -f
Caution
Promotion is permanent and one-way. There is no command that re-attaches a promoted service to its former primary, and once promoted the two services diverge immediately: writes on the old primary never reach the promoted one, and vice versa. Make sure nothing can still write to the old primary’s URI once you have promoted.
Repoint the application at the promoted service’s URI:
exo dbaas show REPLICA_NAME -z REPLICA_ZONE --uriThe promoted service is now an ordinary standalone primary. Review its IP filter, its backup expectations and its maintenance window before you consider the incident closed, and create a new replica for it in another zone: the one you just promoted no longer plays that role.
Scenario 3: The Service Was Deleted
There is nothing to recover from the platform. A fork needs an existing source service: once the
service is deleted, --pg-fork-from answers Service does not exist. Platform backups cannot be
downloaded either. Plan as if deleting a service deletes your ability to recover it, and build
both protections in advance:
Keep termination protection on. It is enabled by default on services created with
exo dbaas create, and a protected service cannot be deleted until it is disabled. Verify it, especially on services created through the API or Terraform, in theTermination Protectedrow of:exo dbaas show my-postgresql -z ch-gva-2Take your own logical dumps, on a schedule you choose. Their cadence is the recovery point of this scenario:
pg_dump --format=custom --file=BACKUP_FILE "SERVICE_URI"Parameters:
BACKUP_FILE: where to write the dump, for examplenightly-2026-08-31.dump.SERVICE_URI: the connection URI of the service, fromexo dbaas show my-postgresql -z ch-gva-2 --uri.
Store the files outside the platform, and keep them at least as long as your recovery obligations.
If the service is gone anyway, create a new service and restore the most recent dump into it:
pg_restore --no-owner --no-acl --dbname "TARGET_URI" BACKUP_FILEParameters:
TARGET_URI: the connection URI of the database to restore into, on the new service.
For restore options and the errors these two flags avoid, see Migrate to Managed PostgreSQL.
Rehearse Quarterly with a Fork Drill
A recovery procedure you have never run is a hypothesis, not a runbook. Because a fork never touches its source, you can rehearse the whole path on production data with zero risk, so put a drill on the calendar every quarter:
Fork production from its latest state:
exo dbaas create pg PLAN FORK_NAME -z ch-gva-2 \ --pg-fork-from my-postgresql \ --pg-ip-filter CIDRTime how long the fork takes to reach
running, then read its URI, connect, and run the checks your application depends on: the tables you expect, the freshest rows you expect. That time, plus your verification, is your recovery time for the fork path. Write it down.Rehearse the dump path in the same session, against the fork so production stays untouched: restore your latest
pg_dumpfile into a scratch database on the fork and check it. Create the scratch database withCREATE DATABASE drill_restore;, restore with thepg_restorecommand above pointing at it, verify, thenDROP DATABASE drill_restore;.Delete the fork:
exo dbaas update FORK_NAME -z ch-gva-2 -f --termination-protection=false exo dbaas delete FORK_NAME -z ch-gva-2 -f
Note
The promote path cannot be rehearsed for free: promotion is one-way, so a promotion drill consumes the replica, and getting replication back means deleting the promoted service and creating a fresh replica that copies the data again from scratch. If you drill it, budget for the rebuild. The automatic failover inside multi-node plans cannot be rehearsed at all.