Skip to content

Recover across regions and restore data

10 min reading

Distinguish failover from restoration; reason about data loss and recovery objectives

Page details

System Design · Operate the system

10 min reading · 23 min with practice

Sources

Published · Last edited:

Prerequisite: Change a running system safely. For basics, use the independent System Design foundations.

More
20px

Hypothetical scenario. Northwind’s maintenance operation deletes reservation records, and replication carries that deletion to the standby. Dev offers the other region as recovery. Priya asks whether it contains the earlier correct state or the same current mistake.

Dev: “The other copy is available.”

Maya: “Available with which data, and what must be reconciled after we use it?”

Separate regional failover from historical restoration. Name the failure being survived, the retained recovery point and the authority needed after the transition. The selected restoration durations are assumptions to derive from, not measured recovery promises.

Which failure must this recovery plan survive?

A standby can help when the current machine or region becomes unavailable. It may not help when valid replication faithfully distributes an unwanted deletion. Retained history and a usable restore process address that second problem. Copies, historical recovery points and operational authority are different assets.

Northwind inventories the database, archived change history, object versions, identity configuration, encryption-key access and the workflow evidence needed to explain external actions. A backup of rows alone may omit the credentials or configuration required to use those rows. Inventory each dependency and identify which failure domain can remove it.

Also define the permitted loss boundary. A recovery point objective expresses the desired limit on lost state under a specified event. A recovery time objective expresses the desired restoration interval. Neither is established merely by naming a region or scheduling backups. Evidence comes from the actual retained positions, dependencies and exercised recovery procedure.

Choose promotion or restore deliberately

For failover, inspect which accepted changes reached the candidate, which are durable and which are applied. Exclude the old writer before granting new authority. A replica answering health probes cannot establish that it contains the required acknowledged history or can absorb the admitted workload.

For historical restore, choose a recovery target and reconstruct a consistent database state from a suitable base and retained history. PostgreSQL’s continuous-archiving mechanism is one concrete option. Its prerequisites include the needed archive sequence. A missing segment can make a desired point unreachable even when a recent backup file exists.

Current copies and historical recovery solve different failuresAn authoritative writer replicates current state to a standby, including unwanted logical changes. A separate retained base and archive support reconstruction of an earlier state. Before restored state accepts work, authority, permissions and external obligations must be reconciled.Writer: current historyStandby: copied historyRetained base + archiveEarlier recovery pointRestore and reconcileThen authorize service
A successful copy is not proof of a successful business recovery.

Restore state and then reconcile the outside world

Hypothetical scenario. Restore a PostgreSQL base backup and the required WAL archive into a fenced recovery environment. Validate the intended recovery position and application invariants before changing traffic. Access to encryption keys, configuration and restore capacity is part of the path, not an assumed free prerequisite.

Restore state and then reconcile the outside world — selected design evidence
Recovery evidencePurposeOwner decision
Base + WAL chainReach coherent chosen positionValidate archive continuity
Fence / routing epochOne admitted authorityExclude old writer
External operation ledgerCompare unreversed remote historyReconcile uncertain intentions
The restore completes before traffic admission; external reconciliation can leave specific operations pending.The restore completes before traffic admission; external reconciliation can leave specific operations pending. Backup / WAL to Recovered DB: 1 · restore + validate; Recovered DB to External provider: 2 · reconcile original operations; Recovered DB to Traffic: 3 · admit gradually after fencing.Backup / WALRecovered DBExternal providerTraffic1 · restore + validate2 · reconcile original operations3 · admit gradually after fencing
The restore completes before traffic admission; external reconciliation can leave specific operations pending. Enlarge the diagram to inspect its labels; the surrounding records and explanation give the text alternative.

A regional replica can survive one infrastructure failure while faithfully replaying a logical mistake. Point-in-time recovery serves a different need from promotion. State the selected recovery point and the corresponding uncertainty in accepted changes; an elapsed backup interval alone does not identify exactly which transactions survive.

The payment provider, issued capabilities and clients do not rewind with the local database. An operation recorded after the restore point may already have happened remotely. Recover original operation identities from retained evidence and reconcile before creating replacement effects. Warm caches and gradual admission protect useful capacity during recovery, but neither replaces the old-writer fence.

Derive the restoration path

Hypothetical worked example. Choose a twenty-minute recovery objective. Select eight minutes to obtain and restore a usable base, four minutes for archive replay, three minutes for validation and two minutes for routing and admission changes. Assume these steps are serial for this exercise. Their sum is 8 + 4 + 3 + 2 = 17 minutes.

The nominal remaining margin is 20 − 17 = 3 minutes. That margin must cover any omitted required work; it is not automatically spare capacity. If key access or provisioning was excluded, the estimate is incomplete. Parallel steps could change the path, but only after the procedure establishes which dependencies really permit overlap.

Choose an archive gap of two minutes at the incident boundary and a steady two accepted changes per second, solely for an exposure estimate. Two minutes contain 2 × 60 = 120 seconds. The interval contains 120 × 2 = 240 accepted changes under the fixed-rate model. That count does not prove all were lost; inspect actual positions and other surviving evidence before drawing that conclusion.

A restored database cannot rewind the provider

Suppose the selected recovery point precedes a payment that the provider later confirmed. The restored workflow record may again say pending or may be absent. The provider’s actual effect survives. Reissuing the action with a new identity can duplicate it, just as in the timeout lesson.

Retain the evidence necessary to reconcile accepted operations across the restoration boundary. Determine which external identities, receipts or independent records survive and what the provider permits for lookup and replay. Where evidence is incomplete, expose uncertainty and an authorized recovery path instead of automatically repeating every missing local action.

The same issue applies to object references and permissions. A restored metadata row can point to an object version no longer retained. A restored access policy can accidentally re-enable a previously revoked grant. Validate the composed system state before allowing broad reads or accepting new effects.

In the wild: recovery has concrete prerequisites

PostgreSQL’s continuous-archiving documentation describes base backups, retained WAL and point-in-time recovery. Use it to inspect the chosen database procedure. It does not certify object-store consistency, provider reconciliation or the application’s recovery time.

The backup job is green but recovery stops

Hypothetical failure scenario. Backup uploads finish successfully, but a restore exercise cannot obtain a required encryption key under the recovery role. Another archive segment is missing. The dashboard reported successful copying while the desired recovery point remained unusable.

Exercise the restore with the actual recovery identity and isolated target. Validate completeness, integrity, supported software versions and the chosen application invariants. A destructive incident should not be the first occasion on which the organization discovers its recovery permissions. Record observed durations and gaps without turning one successful exercise into a universal guarantee.

Restore useful capacity gradually

A new region can be correct and still overloaded by a cold cache, replay backlog and normal traffic arriving together. Use the admission and refill policies developed earlier. Reserve enough capacity to finish reconciliation and observe successful useful outcomes while increasing admitted work.

Routing also converges through several layers. Previously resolved endpoints, active connections and background clients may continue contacting the old location. The enforcing writer boundary must reject obsolete authority independently of the visible routing change. Rejoining the old primary requires a supported procedure for the selected history.

Use the recovery mechanism that matches the loss

Use a current suitable replica for failures where its accepted history and authority meet the contract. Use retained historical state for logical corruption or deletion when a correct earlier point exists. Neither path removes the need to reconcile externally visible actions. Avoid promising recovery from threats outside the retained data and trust model.

This chapter does not choose a universal archive retention interval or backup vendor. Those depend on recovery objectives, detection delay, data growth and operational evidence. The decision record should identify the current policy, the latest exercise and the conditions under which the team must refuse promotion or restoration.

Challenge the proposed mechanism

A restored database says a charge is absent while the provider says it succeeded. Which record wins?

Reveal the design reasoning

The provider supplies evidence of its external effect; absence from the restored local prefix cannot negate it. Reconcile the original business intention, repair local evidence and avoid a second charge. Keep unresolved identity gaps visible.

Decision and reconsideration: Test restore, authority fencing and external reconciliation together. Use measured rehearsal evidence before claiming the recovery objective.

Defend the recovery claim

  1. An unwanted deletion reaches every standby. Does another region solve it?

    Identify historical state

    Not by copying the same current state. Recover an earlier consistent point where supported history exists, then reconcile later accepted obligations and external effects.

  2. The selected restore takes seventeen minutes against a twenty-minute objective. Is the objective proved?

    Inspect assumptions and missing work

    No. The three-minute margin is arithmetic under selected serial durations. Actual provisioning, key access, validation, routing and reconciliation need evidence from the procedure.

  3. A restored database lacks a provider success record. May the operation be recreated?

    Preserve external history

    No from local absence alone. The provider effect may survive. Reconcile the original identity through retained evidence and the supported provider contract.

Recovery must preserve the meaning of restored state, not merely its existence. Page 39 examines a smaller state question: what a distributed count means when writes, retries and observations are spread across owners.

Northwind decision log

Separate current replication from recoverable historical state.
Exercise recovery dependencies, authority and external reconciliation.
Next, distribute a hot aggregate without inventing a single current count.

Go deeper: recoverability before backup settings