Unit 7 of 15 · about 4 hours · explain, implement
Replication versus backup and verified backup and restore
Replicas copy corruption, deletion and schema mistakes within seconds. Only a tested restore path answers the question the incident will ask: what can you bring back, and how do you know.
You'll be able to
- Distinguish replication from backup by which failures each survives.
- Take base plus WAL backups and restore them to a stated recovery target, and replay a logical log to a target with winner-only semantics.
- Verify restores by replaying into an isolated target and checking data, not by trusting the backup job's exit code.
Covers
Read
In this order, only the parts listed
0 of 4 done
- Base backup and WAL replayThe Internals of PostgreSQL - Base Backup and Point-in-Time Recovery
10.1 Base Backup (
pg_backup_start,pg_backup_stop,pg_basebackup, Backup Manifest Files) (page read 2026-10-15) - How point-in-time recovery worksThe Internals of PostgreSQL - Base Backup and Point-in-Time Recovery
10.2 How PITR Works (REDO start from the
backup_label,restore_command,recovery_target_time, commit versus abort record handling) (page read 2026-10-15) - Where recovery stops and what verification provesPostgreSQL 18 Documentation - Recovery Targets, Backup Verification and Rewind
Section 19.5.6 Recovery Target:
recovery_target_lsnandrecovery_target_inclusive; then thepg_verifybackupreference (https://www.postgresql.org/docs/18/app-pgverifybackup.html) on what manifest checks cannot cover - Design for recovery: what you recover fromGoogle SRE Books - SLOs, Monitoring, Overload, Cascades, Incidents and Recovery
What Are We Recovering From (Random, Accidental, Software and Malicious errors); Design Principles for Recovery (go as quickly as possible, guarded by policy)
Read for the failure categories that backups must cover. The revoke and rollback sections belong to the rotation and migration units.
Focus on
- Replication answers node death; backup answers data death. A second replica replays the bad delete just as faithfully as the good write.
- In the practice simulator, replay only transactions committed by the inclusive target LSN. PostgreSQL instead redoes physical WAL through the recovery target, and MVCC with transaction status keeps uncommitted effects invisible. Do not equate the two.
- Keep and verify the backup manifest when there is one: it detects missing or changed files. A manifest is not required for full-backup recovery and does not replace an isolated test restore with data checks.
- Design for the incident categories first: random, accidental, software and malicious errors each stress a different part of the restore path.
Common mistakes · 3
- Promoting a standby and calling it a restore test. Failover exercises replication, not the backup chain; the WAL archive may have been broken for months.
- Replaying past the target. In the exercise, records at the target LSN apply and records after it do not, so a commit at the target makes its transaction a winner. In PostgreSQL, set the target and
recovery_target_inclusiveexplicitly. - Trusting the backup job's success status. Verification means replaying into an isolated target and reading the data back.
Try it yourself
Closed-book, before checking anything
Quiz yourself
Answer first, then mark it. Missed ones go to Review.
0 got · 0 missed
1.A bad
DELETEcommits and replicates to all standbys. Does failover recover the rows?AnswerNo. Replication copies the delete. Only a backup from before the commit, replayed to a point before it, brings the rows back.
2.Transaction 1 commits before the target LSN and transaction 2 is still open at it. Which effects survive recovery?Answer
Only transaction 1's. In the simulator, winners need a commit record at or before the target and every operation of the open transaction is ignored. PostgreSQL redoes the physical WAL to the target, and transaction status keeps the open transaction's rows invisible.
3.What does the backup manifest add, and what does it not prove?Answer
It lists the backup's files with checksums, so
pg_verifybackupcan detect missing or changed files. It cannot run every check a live server would, so a test restore with data checks is still required.4.Which incident category does a tested restore address that RAID and replicas do not?Answer
Accidental and malicious errors: mistaken or hostile writes that the storage layer and replicas faithfully preserve.
Practice
- AlgoMaster: Replay WAL to a Point in Time
recoverreplays winner puts and deletes in increasing LSN order and returns rows sorted by key; the page tests that uncommitted transactions leave no effectThe section mini-project covers this: take a base backup and WAL archive, restore into an isolated target, and verify committed data, tenant predicates and the current deletion policy.
You're done when
Your simulator handles the winner set, and an isolated restore from your own backup and WAL passes data and policy checks.
Only when you can do this without notes.
Leads to
- Recovery point and time objectives and disaster-recovery failover and failbackPut recovery-point and recovery-time numbers on the verified restore.
- A load, chaos, backup and restore campaign with capacity, recovery and migration costsSchedule restores as recurring chaos scenarios, not one-off checks.
Notes
Resources · 3 for this unit, 14 more in the section
- Google SRE Books - SLOs, Monitoring, Overload, Cascades, Incidents and RecoveryGoogle · required
Read SRE Chapter 4 (service level objectives), 6 (monitoring distributed systems), 21 (handling overload), 22 (addressing cascading failures), 14 (managing incidents) and 15 (postmortem culture); Workbook Chapter 2 (implementing SLOs) and 5 (alerting on SLOs); and Building Secure and Reliable Systems Chapter 5 (least privilege) and 9 (design for recovery). Convert each into one alert, limit, load test or runbook action in the capstone.
- The Internals of PostgreSQL - Base Backup and Point-in-Time RecoveryHironobu Suzuki · support
Read Chapter 10 (base backup, how PITR replays WAL, timelines and incremental backup) as the real-engine model for backup integrity, recovery points and restore verification. Note the date you read it.
- PostgreSQL 18 Documentation - Recovery Targets, Backup Verification and RewindPostgreSQL Global Development Group · reference
Read Section 19.5.6 Recovery Target, the
pg_verifybackupreference and thepg_rewindreference for recovery stopping points, manifest checks and rejoining a diverged primary.
Also in this section
- HLD Handbook - Reliability, Operations and Security at ScaleHLD Handbook · primary
Read Part 6 observability, SLOs, resilience, overload, deployments, chaos, incidents and health, then Part 7 authentication, mTLS, secrets, tenancy and data governance chapters relevant to the capstone. Skip unrelated case studies.
- DDIA 2e - Chapters 2, 5 and 14Martin Kleppmann and Chris Riccomini · support
Use Chapter 2 "Describing Performance" for percentile and response-time vocabulary and Chapter 5 for compatibility during rolling upgrades. Chapter 14 is about predictive analytics, privacy and data governance, not operations: read its "Privacy and Tracking" section for the retention and deletion units.
- Metastable Failures in Distributed Systems (Bronson et al., 2021)HotOS · support
Read the trigger and sustaining-effect model of metastable failure and the retry and shedding design prompts. Its model illustrates; it does not predict.
- Metastable Failures in the Wild (Huang et al., 2022)USENIX OSDI · support
Read the incident study for how retries and load sustain outages after the trigger ends; it is a sample of public reports, not a rate.
- Simple Testing Can Prevent Most Critical Failures (Yuan et al., 2014)USENIX OSDI · support
Read the findings on error-handling code and how few nodes and events reproduce most failures, as the case for testing error paths in your campaign. Its bounds come from one sample of 2014 systems.
- Gray Failure: The Achilles' Heel of Cloud-Scale Systems (Huang et al., 2017)Microsoft Research · support
Read the gray-failure model (differential observability between a detector and its clients) as vocabulary for telemetry and failure detection.
- Building Distributed Systems - The Tracer, The Securitor and The MigratorBuild Distributed Systems · optional
Only the first three tasks of each track are free: in The Tracer, trace-context propagation, span lifecycle and a collector; in The Securitor, JWTs, the OAuth 2 code flow with PKCE and sessions; in The Migrator, schema migrations, expand and contract, and zero-downtime change. Tasks are graded in the browser after login, so treat a pass as a drill and keep your local harness as the evidence.
- SPIFFE Workload Identity and Workload APISPIFFE Project · support
Read the SPIFFE ID, X.509-SVID and trust bundle specifications and the Workload API (
FetchX509SVID,FetchX509Bundles) to design service identity, short-lived credentials and bundle rotation. A local mock is sufficient unless a real SPIRE deployment answers a specific gap. - OpenTelemetry Signals and Semantic ConventionsOpenTelemetry · support
Read signals and context propagation (W3C Trace Context
traceparent, inject and extract, baggage rules), then the semantic conventions (1.44.0) for the RPC and messaging areas with their stability status. Define bounded attributes for request, node, partition, term and offset identities, and never infer global order from display timestamps. - Replicated Log and Stream Processor - Production ContractRoadmap-Final · support
Add workload identity, tenant checks, audit, SLOs, capacity limits, backup and verified restore, mixed-version migration, rollback and reduced point-in-time ML data paths. Run one compound incident from detection through recovery.
- OWASP Threat Modeling Cheat SheetOWASP · reference
Use System Modeling (data-flow diagrams, trust boundaries, stores and processes), Threat Identification (the STRIDE table applied to components, data flows and trust boundaries) and Response and Mitigations to build the unit threat model.
- Feast Documentation - Point-in-Time Joins and Feature RetrievalFeast · support
Read Point-in-time joins (entity dataframes,
get_historical_features, TTL backward scan,filter_by_created_timestamp) and Feature retrieval (event_timestampas the inclusive upper bound,get_online_featureswithout timestamps, feature services per model version, materialize refresh). Work the join logic on tiny local tables; do not deploy Feast. Page read 2026-10-15 (v0.66-branch documentation). - MLflow Model Registry DocsMLflow · support
Read the Model Registry page (registered models, versions, lineage to the producing run, aliases such as @champion, and tags) and the registry tutorial promotion flow. Stages are deprecated since MLflow 2.9; use aliases and tags. Page read 2026-10-15; the versioned docs move, so re-pin the version you read.
- DVC Docs - Data VersioningDVC · support
Read
dvc add(Description and Example: Single file) for.dvccontent-hash sidecars, thedvc.yamlpage with itsdvc.lock filesection for pipeline state, andpushandpullfor transfer. A local directory remote is enough; do not set up cloud storage. Page read 2026-10-15.