Cloud

Azure PostgreSQL: validate a point-in-time restore before production cutover

A production runbook for selecting a PostgreSQL restore point, proving recovered data and choosing between targeted recovery, cutover and keeping the source.

18 Nov 2026 azurepostgresqlbackuprestorepitrdata-recoveryobservabilityrunbookrollbackproduction

An application migration accidentally deletes order rows. New orders are still arriving and high availability is healthy: it has replicated the deletion too. Restoring to the latest available point may retain the error; switching immediately to an older copy may discard legitimate writes made since then.

This runbook uses Azure Database for PostgreSQL Flexible Server. The goal is not merely to create a restored server. It is to select a defensible point in time, prove that the required data is present, and decide how to recover it without silently overwriting recent work.

Contain the incident and establish a timeline

Stop the faulty process and its retries before restoring. If its behavior is still uncertain, pause the affected writes with the business owner. Preserve the source server, logs, deployment identifiers, application audit records and event queues. Do not delete the server to start over.

yaml 01-recovery-evidence.yml
incident: INC-DATA-1842
source_server: pg-orders-prod
first_bad_operation_utc: "2026-11-18T08:14:30Z"
last_proven_good_utc: "2026-11-18T08:13:45Z"
candidate_restore_utc: "2026-11-18T08:13:40Z"
affected_scope: orders and related order_lines
writes_after_candidate: inventory from application and event logs
decision_owner: incident commander and data owner
constraints:
- preserve source and audit evidence
- no production writer on restored server during validation
- measure acceptable data loss and recovery time

These timestamps are illustrative. Establish the upper boundary of the destructive operation from multiple sources: a deployment time is not necessarily the SQL commit time. Check that the selected point is available in the service’s restore window. If the boundary remains uncertain, plan for multiple candidates and their cost. A timestamp before the incident alone does not prove business consistency.

Understand the restore boundary

PITR creates a new server; it does not overwrite the source. A custom point must be inside the available retention window, and the restore covers the server and its databases, not just one table. The service recovers from a backup and transaction logs. A logical error replicated to the standby is not fixed by an HA failover.

Compare the recovery time actually observed with the recovery objective rather than promising a fixed duration. A point-in-time restore stays in the source region, while networking choices depend on the source server’s access mode. Review the backup, restore and networking rules and post-restore tasks before proceeding.

Restore into an isolated boundary

Prepare a distinct name, operational permissions, networking and the cost of the candidate server. Document allowed access. Prevent applications, scheduled jobs and integrations from treating this copy as production; a new name alone is not a write fence. Check outbound connections, external jobs and the credentials or connection strings used for testing.

The following example creates a billable resource. It assumes the source and resource group are known, the restore window has been checked and applicable networking choices have been prepared. Adapt it to the environment and current service constraints.

bash 02-restore-candidate.sh
az postgres flexible-server restore \
--resource-group "<resource-group>" \
--name "<unique-restored-server>" \
--source-server "<source-server>" \
--restore-time "2026-11-18T08:13:40Z"

Follow the operation to completion, record its identifier and the resulting FQDN, then test name resolution, network path, TLS and identity from an authorized administration host. Check the settings, extensions, access, monitoring and HA configuration needed for production use. Do not broadly open the network to speed up diagnosis.

Prove the data, not just the Azure status

Use a read-only account and queries adapted to the actual schema. Compare affected records with an independent source, together with relationships and business totals. These examples are templates: replace the columns and time bounds, and account for load before running expensive queries.

sql 03-validate-recovered-orders.sql
-- Read-only validation on the isolated candidate.
SELECT count(*) AS affected_orders
FROM orders
WHERE created_at >= TIMESTAMPTZ '2026-11-18 00:00:00+00'
AND created_at <  TIMESTAMPTZ '2026-11-19 00:00:00+00';

SELECT count(*) AS orphan_lines
FROM order_lines l
LEFT JOIN orders o ON o.id = l.order_id
WHERE o.id IS NULL;

Matching counts do not prove contents or integrity. Check expected identifiers, versions or states, constraints and selected end-to-end transactions. Measure legitimate writes and events between the chosen point and the actual write freeze, including external side effects. If they cannot be inventoried or reconciled, the loss is unknown: do not declare the copy ready to replace production.

Choose targeted recovery or cutover

For a small set of identified objects, prefer targeted recovery when dependencies are understood: export from the candidate, review the diff and prepare a transactional reintroduction tested on a copy. Freeze affected writes, detect conflicts with newer data and have exceptions approved. A blind overwrite import can destroy legitimate corrections.

For a full cutover, obtain explicit acceptance of data loss and downtime. Stop every writer and consumer, confirm that in-flight transactions have drained, capture final offsets or queue state, and preserve connection configuration. Reconcile or accept writes after the restore point before changing connections to the candidate FQDN. Persistent connections must be renewed. Test controlled reads and writes, asynchronous processing, identity, alerts and backups before gradually reopening traffic.

yaml 04-cutover-gates.yml
candidate:
restore_point_utc: "2026-11-18T08:13:40Z"
integrity_and_business_checks: passed
post_restore_writes: inventoried_and_reconciled
network_identity_tls: verified
monitoring_backup_and_ha: verified_or_accepted_exception
cutover:
writers_fenced: true
in_flight_work_drained: true
data_loss_and_downtime_approved: true
source_preserved: true
owner_and_rollback_trigger: recorded

These are gates to prove, not observed results. If any gate is missing, keep the candidate isolated and continue the investigation.

Rollback and closeout

Before any write reaches the candidate, restoring the source connection configuration can reverse the cutover if the original cause is contained. Once writes are allowed, the servers diverge: returning to the source without reconciling new transactions would lose data again. Stop writers, inventory changes on both sides and execute an approved reconciliation plan before switching back.

Retain evidence, start and finish times, decisions, RPO/RTO deviations and the source server according to the retention policy. Delete an unused candidate only after approval and the agreed retention period. The right decision may be to recover a few rows, cut over with an accepted loss, or defer cutover until recent writes are understood.