Summary#
Disaster recovery (DR) is the plan, and the machinery, for getting a service and its data back after a failure that high availability can't absorb. That might be a lost region, a deleted database, ransomware or silent corruption. Two numbers drive the plan:
- the RPO (recovery point objective): how much recent data you can afford to lose;
- the RTO (recovery time objective): how long you can afford to be down.
Backups (full, incremental, snapshots, point-in-time recovery) protect the data. The four DR strategies, from backup-and-restore to multi-site active-active, trade cost against recovery time. None of it counts until it has been tested by actually restoring.
Why It Exists#
High availability keeps a service running through expected failures: a server, a rack, a zone. It does this with live redundancy, meaning replicas that are always in sync. That same property makes HA useless against a whole class of disasters:
- Logical corruption replicates. If a bug, a bad migration or an operator runs
DELETE FROM orderswithout aWHEREclause, every synchronous replica deletes the rows within milliseconds. Replication protects against losing a copy. It doesn't protect against a wrong write. - Ransomware and malicious deletion target everything an attacker can reach, including the replicas, and often the backups too.
- Regional or provider disasters take out every zone at once: a fire, a flood, an extended regional outage, a cloud account suspended or compromised.
- Gradual, silent damage goes unnoticed for days. A bug writes slightly wrong data, or a disk returns corrupted blocks. By the time anyone notices, every replica and every recent backup contains the damage.
DR exists because the answer to these events must be a copy of the data from before the damage, kept somewhere the damage couldn't reach, plus a practised way to bring the service back on top of it.
The stakes are real and well documented.
- GitLab, January 2017. During an incident, an engineer accidentally deleted the data directory of GitLab.com's primary database. The team then found that several of its backup and replication methods weren't working as believed. The data was restored from a staging snapshot taken about six hours earlier, so about six hours of production data were lost. GitLab published the incident openly, and it has become a standard lesson that untested backups are not backups.
- OVHcloud, March 2021. A fire at the Strasbourg site destroyed one data centre and damaged another. Customers whose only backups lived on the same site lost data permanently.
- Code Spaces, 2014. An attacker who gained access to the company's AWS control panel deleted much of its infrastructure, including backups stored in the same account. The company shut down.
How It Works#
A DR plan has four layers:
- Objectives: the RPO and RTO for each service and data class, set by the business.
- Protected copies: backups, snapshots and continuous logs, stored in isolated locations, with enough history to go back to before the damage.
- A recovery strategy: the standing infrastructure and the runbooks to bring the service back within the RTO. The options range from rebuilding everything from backups to having a second live site.
- Verification: regular restores and failover drills that prove the objectives are met.
RPO and RTO#
The recovery point objective (RPO) is the maximum acceptable amount of data loss, measured in time. An RPO of 15 minutes means that after a disaster you may lose at most the last 15 minutes of writes. The recovered data will reflect a state no more than 15 minutes old.
The recovery time objective (RTO) is the maximum acceptable time from the disaster until the service is working again. An RTO of 4 hours means users may be without the service for at most 4 hours.
The two objectives are independent, and they cost different things.
- RPO is a property of how often and how far you copy data. Nightly backups give an RPO of up to 24 hours. Continuous log shipping gives seconds to minutes. Synchronous replication to another site gives an RPO of zero.
- RTO is a property of how much standing infrastructure and automation you have. It covers how long it takes to provision servers, restore terabytes, replay logs, reconnect dependencies, verify and redirect traffic.
Objectives are set per service and per data class, through a business impact analysis: what does an hour of downtime, or an hour of lost data, cost in revenue, contracts, regulation and trust? A typical tiering:
| Tier | Examples | RPO | RTO |
|---|---|---|---|
| 0: mission critical | Payments ledger, order capture, identity | 0 – seconds | Minutes |
| 1: business critical | Customer-facing product catalogue, messaging | Minutes | Under 1 hour |
| 2: important | Internal tools, reporting, search indexes | Hours | Hours to a day |
| 3: deferrable | Analytics history, archives, dev environments | 24 hours | Days |
Two related terms often appear in DR plans.
- MTD (maximum tolerable downtime): the point at which an outage threatens the business itself. The RTO must be comfortably inside it.
- Recovery consistency objective: across several data stores, how consistent with each other they must be after recovery. This becomes important in microservice systems, and is covered in a deep dive below.
RPO and RTO, in depth: making the numbers concrete#
Deriving the RPO you actually have. The achieved RPO for a data store is the age of the newest copy that survives the disaster. That depends on the mechanism:
- Periodic backups every T hours: the worst-case RPO is T, plus the backup's own duration if the backup is taken as a snapshot at its start. The average is about T / 2.
- Continuous archiving of the write-ahead log (WAL in PostgreSQL, the binlog in MySQL) to object storage: the RPO is the archive delay. That is how long a WAL segment waits before it is shipped. PostgreSQL ships 16 MB segments when they fill, or after
archive_timeout. A quiet database witharchive_timeout = 60shas an RPO of up to about a minute. Streaming tools such as pgBackRest's async archiving, WAL-G or Barman's streaming mode can cut this to seconds. - Asynchronous replication to another region: the RPO is the replication lag at the moment of failure. That's typically under a second, but it grows to minutes under heavy load or when the link degrades. That is exactly when disasters tend to happen, so measure lag at p99 under peak, not on average.
- Synchronous or consensus replication across sites: the RPO is zero for acknowledged writes, paid for with write latency.
Against logical damage, the RPO is set by detection time. If corruption is noticed after 3 days, you need a restore point from before it began, so retention must cover your worst plausible detection delay. Point-in-time recovery lets you pick the moment just before the bad write. The writes after that moment then have to be recovered selectively, or reapplied.
Deriving the RTO you actually have. The RTO is a sum:
- Detection and decision: noticing the disaster, and deciding to invoke DR. Declaring a disaster is often a human decision, and it commonly takes 15–60 minutes.
- Infrastructure: provisioning compute, networks and load balancers, unless they are already standing.
- Data restore: copying backup bytes into the new environment.
- Log replay: rolling the restored base backup forward to the target time.
- Application bring-up and verification: starting services, warming caches, smoke tests, integrity checks.
- Traffic redirection: DNS changes, client reconnection, and partners updating allow-lists.
The data restore often dominates. Restore throughput is bounded by the slowest link: object-store read throughput, network, or the target disks' write throughput. Here is a worked example.
- Data: a 10 TB database.
- Restoring from object storage with parallel streams achieves a sustained throughput of about 500 MB/s.
- 10 × 10¹² B ÷ 5 × 10⁸ B/s = 20,000 s ≈ 5.6 hours, before any log replay.
- Log replay: a database that writes 50 GB of WAL a day, restored from a base backup that is 6 days old, must replay about 300 GB. Replay speed is commonly limited by random I/O. At about 100 MB/s, that is about 50 minutes.
So a stated RTO of 1 hour is impossible with backup-and-restore for this database, however good the runbook. Restoring from a block-storage snapshot can be faster, because many clouds create volumes from snapshots lazily and load the blocks on first access, but with a performance penalty until they are warm. A warm standby avoids the restore entirely.
RPO and RTO are promises about the worst case, under stress. Measure them in drills, not on paper. The figure that matters is the measured RTO and RPO from the last full test, not the design target.
Backup types#
A backup is a copy of data, taken at a point in time and stored separately from the original, from which the data can be restored. Backups differ in what they copy each time, and in how they are taken.
Full backup. A complete copy of the data set. Restoring needs only this one backup, so it is simple and fast to restore. But each full backup copies everything, which takes the longest, uses the most storage and loads the source the most. Daily fulls of a 10 TB database mean 10 TB of new backup data every day.
Incremental backup. Copies only what changed since the previous backup of any kind. Incrementals are small and quick, and the daily volume is just the day's changes. Restoring needs the last full plus every incremental since, applied in order. A missing or corrupt link in that chain breaks every later restore point.
Differential backup. Copies everything that changed since the last full backup. Each differential grows over the week, but a restore needs only the full plus the latest differential. This is a middle ground between full and incremental.
Snapshot. A point-in-time image of a volume, file system or database, taken almost instantly by the storage layer. Instead of copying the data, a snapshot freezes the current block map:
- copy-on-write snapshots copy a block to the snapshot area just before it is overwritten;
- redirect-on-write snapshots write new data to new blocks, and keep the old ones for the snapshot.
ZFS, LVM, storage arrays, and cloud disks (EBS, Persistent Disk, Azure managed disks) all offer snapshots. Cloud block snapshots are also incremental. After the first one, each snapshot stores only the blocks that changed, while still restoring as a complete volume. A snapshot that stays on the same storage system is not a backup against that system failing. Cloud snapshots are stored in the provider's object storage, separately from the volume, which is why they count. Copy them to another region or account for DR.
Point-in-time recovery (PITR). Restore the database to any moment in the retention window, not just to backup times. PITR combines a periodic base backup (a full or snapshot copy of the data files) with a continuous archive of the database's write-ahead log (WAL), the sequential record of every change. To restore to 14:32:10 on Tuesday, you restore the most recent base backup before that time, and replay the archived log up to exactly 14:32:10. PITR is the standard defence against logical errors. If someone dropped a table at 14:32:11, you restore to one second before. Managed databases expose PITR as a feature, usually with a retention window of up to 35 days (RDS, Aurora, Cloud SQL, Azure SQL). DynamoDB offers PITR with per-second granularity over 35 days.
Backups are also either logical or physical.
- A logical backup is a dump of the data as statements or rows, made with
pg_dump,mysqldumpormongodump. It is portable across versions and platforms, and it can restore a single table. But it is slow for large data sets, because restore means re-inserting every row and rebuilding every index. Dumping a multi-terabyte database can take many hours. - A physical backup is a copy of the data files themselves, made with pgBackRest, Barman, WAL-G or Percona XtraBackup, or from storage snapshots. It is fast to take and restore, and it supports PITR. But it is tied to the database version and configuration, and usually restores the whole cluster.
Large systems use physical backups plus PITR for DR, and logical exports for portability, compliance and single-table recovery.
Backup types, in depth: rules, retention and consistency#
The 3-2-1 rule. A long-standing guideline:
- keep at least 3 copies of the data (the production copy plus two backups);
- keep them on 2 different kinds of media or storage system;
- keep 1 copy off-site.
A modern extension, sometimes written 3-2-1-1-0, adds 1 copy that is offline, air-gapped or immutable, and 0 errors, verified by restore testing. In cloud terms, "different storage system" and "off-site" typically mean a different region and a different account, with separate credentials. A backup that the production account's administrators, or an attacker with their credentials, can delete is not protection against them.
Immutability. Write-once-read-many (WORM) storage prevents deletion or modification of backups until a retention date, even by administrators. Examples:
- S3 Object Lock in compliance mode, which can't be shortened or removed even by the root user;
- Azure immutable blob storage;
- GCS bucket retention policies, with locked retention;
- AWS Backup Vault Lock.
These are the main technical defence against ransomware that targets backups. Pair them with deletion delays (soft delete with a recovery window) and alerts on any change to backup policies.
Retention. How far back can you go? A classic scheme is grandfather-father-son (GFS): keep daily backups for a week or two, weekly ones for a month or two, monthly ones for a year, and yearly ones for as long as compliance requires. Retention must cover:
- your worst plausible detection delay for silent corruption;
- legal and regulatory needs (financial records are commonly kept for years);
- privacy law. GDPR's erasure rights apply to backups too. A common approach is to keep backups encrypted and short-lived enough that erased data ages out, and to re-apply deletions after any restore.
Consistency of what you back up. A backup is only useful if the restored data is internally consistent.
- A crash-consistent snapshot captures the disk as it would be after a sudden power loss. A database with a write-ahead log recovers from that state correctly, by replaying or rolling back the log. But only if all its volumes are snapshotted at the same instant, which needs multi-volume snapshot groups.
- An application-consistent backup coordinates with the application: flushing buffers, briefly quiescing writes, or using the database's own backup API, such as PostgreSQL's
pg_backup_start. This guarantees a clean restore point. - Physical database backup tools take a consistent base backup while the database runs. They copy the data files and record the WAL range needed to make the copy consistent.
Back up more than the database. A service can't be restored from its rows alone. You also need:
- object storage contents (versioning plus cross-region replication, or periodic copies);
- infrastructure definitions (Terraform, CloudFormation, Kubernetes manifests in Git);
- configuration and secrets (with care: encrypted, with access-controlled copies);
- encryption keys. A backup encrypted with a KMS key that was deleted along with the account can't be decrypted;
- container images and artefacts;
- DNS zones and certificates;
- message logs, if they are a source of truth (Kafka topics used for event sourcing);
- runbooks, stored somewhere that doesn't depend on the failed environment.
Kubernetes cluster state can be backed up with tools such as Velero, but rebuilding from Git (GitOps) is often the cleaner path.
Encrypt backups, at rest and in transit. Restrict restore permissions, because a backup is a complete copy of your most sensitive data. And log every access.
DR strategies#
The four standard DR strategies, popularised by AWS's disaster recovery whitepaper and now used across clouds, form a ladder. Each rung reduces RPO and RTO by keeping more of the recovery environment running ahead of time, and costs more.
1. Backup and restore. Data is backed up to another region (or site). Nothing else runs there. In a disaster you provision the whole environment from infrastructure-as-code, restore the data from backups, start the services and redirect traffic. RPO: hours, or minutes with continuous log archiving. RTO: hours to a day or more, dominated by data restore time. Cost: lowest, just storage and transfer of backups. It fits tier 2 and tier 3 systems, or tier 1 on a budget with small data sets.
2. Pilot light. The core data layer runs continuously in the DR region: a database replica receiving asynchronous replication, and object-storage replication. Everything else is defined but switched off or sized at zero: app servers, caches, queues. In a disaster you promote the replica, deploy or scale up the application tier, and switch traffic. RPO: seconds to minutes (replication lag). RTO: tens of minutes to a few hours, dominated by provisioning and scaling the compute. Cost: low to moderate, the replica database plus replicated storage. The name comes from the small flame in a gas heater that is always lit, so that the full burner can ignite quickly.
3. Warm standby. A complete but scaled-down copy of the production environment runs continuously in the DR region. It has every service, replicas of every data store and working load balancers, at perhaps 10–30% of production capacity. It may even serve a little traffic, such as read-only or internal users, which keeps it honest. In a disaster you promote the data stores, scale the standby up to full capacity and shift traffic. RPO: seconds. RTO: minutes to tens of minutes, mostly scaling time. Cost: moderate to high.
4. Multi-site active-active. Two or more sites each run at full capacity and serve live traffic. Data is replicated between them continuously: asynchronously with partitioned ownership, or with multi-writer or consensus databases. In a disaster, traffic routing simply stops sending users to the failed site. RPO: near zero, or zero with synchronous or consensus writes. RTO: seconds to minutes. Cost: highest, at least 2× infrastructure plus the engineering of multi-region data. This is the territory of high-availability design and Multi-Region Data.
| Strategy | Standing in DR site | Typical RPO | Typical RTO | Relative cost |
|---|---|---|---|---|
| Backup and restore | Backups only | Hours (minutes with log archiving) | Hours to days | Lowest |
| Pilot light | Replicated data stores; compute off | Seconds to minutes | Tens of minutes to hours | Low to moderate |
| Warm standby | Full stack at reduced capacity | Seconds | Minutes to tens of minutes | Moderate to high |
| Multi-site active-active | Full stack at full capacity, serving traffic | Near zero | Seconds to minutes | Highest |
DR strategies, in depth: failover, failback and the details that bite#
Declaring a disaster. Automatic HA failover within a region is routine, but DR invocation is usually a deliberate decision. It costs data (the RPO) and it is disruptive. Suppose the primary region might come back in 20 minutes. Failing over to a pilot light with a 1-hour RTO makes the outage longer, and loses data you would otherwise have kept. A DR plan therefore defines:
- invocation criteria, for example "primary region unavailable for 30 minutes with no provider ETA, or data confirmed destroyed";
- who may declare, with named deputies;
- how the decision is communicated.
The order of operations matters. A typical pilot-light failover:
- Freeze writes to the old primary, if it is reachable at all, so that it doesn't diverge.
- Promote the DR database replica. Record the replication position at promotion, because that defines the data you lost.
- Scale up the application tier from pre-built images and infrastructure-as-code.
- Warm the caches, or rate-limit the database to survive a cold-cache stampede.
- Update service discovery, secrets and configuration to point to the DR resources.
- Run smoke tests and data integrity checks.
- Shift traffic with DNS or global load-balancer weights, gradually if possible.
- Notify partners who need to update IP allow-lists, webhooks or VPN tunnels.
Each of these steps hides traps. Pre-built images may be months old. Quotas in the DR region may cap how many instances you can launch. Third-party dependencies may whitelist only the production IPs. Licence servers may be tied to the original site.
Capacity in the DR region. In a regional disaster, many customers of the same cloud fail over to the same neighbouring regions at once. On-demand capacity there may run short. Organisations with strict RTOs buy capacity reservations in the DR region, or keep a warm standby large enough to carry the critical tier without scaling.
Failback. After the primary region recovers, you usually want to move back. That is a second migration, often harder than the failover, because:
- the DR region is now the primary, with writes the old primary never saw;
- the old primary may hold unreplicated writes from just before the disaster, which conflict with what happened since.
A safe failback rebuilds the old region as a replica of the new primary, and then switches over in a planned, low-traffic window. The unreplicated tail from the old primary is extracted and reconciled separately, by replaying it, merging it or discarding it with a record. Plan and test the failback, not just the failover.
Split brain at the regional level. If the old primary comes back on its own and starts serving users while the DR site is also live, you have two primaries. Prevent it by:
- fencing the old site: disabling its DNS records and load balancers, and revoking its database write credentials;
- having the old site's applications check a global "active site" flag in a strongly consistent store before accepting writes.
DR for the things around the service. Identity providers, CI/CD, artefact registries, monitoring, secrets stores and the incident-management tooling itself all need to work during a disaster. Common practices:
- monitoring hosted outside the region it watches;
- break-glass accounts with credentials stored offline, for when single sign-on is down;
- copies of the runbooks outside the primary wiki.
Cloud provider dependence. The four strategies usually assume a second region of the same provider. Some organisations, often for regulatory reasons, also keep a cross-provider or on-premises copy of critical data. Restoring service on a different provider is much harder than restoring data, because the services, APIs and infrastructure code differ. A realistic middle ground is to keep immutable data backups with a second provider, which protects against account loss or provider-wide failure, while accepting a long RTO for that scenario.
Matching the disaster to the recovery#
"Disaster" covers very different events, and each needs a different recovery mechanism. A plan that only covers "the region is gone" will be useless when the real event is "a bug has been corrupting one column for four days". Classify the scenarios first, and check that each one has a mechanism that can actually reach it.
Infrastructure loss with intact data. A server, zone or region fails, but the data that was replicated before the failure is correct. Within a region, HA handles this automatically. For a region, the DR strategy applies: promote the replica in the DR region, and accept the replication lag as the RPO. This is the scenario that the four strategies are designed for.
Logical damage at a known moment. A bad deploy, an incorrect migration, or a mistaken bulk update or delete. The damage is identifiable, and usually so is its start time, from deploy logs or the database audit log. Replicas are useless here, because they hold the same damage. Restore a copy with PITR to just before the event, then decide how to merge:
- Restore the affected objects into production. Copy back the deleted rows or tables. Writes made since then to unaffected data are kept. This is the usual choice.
- Roll the whole database back to the restore point, losing all writes since. This is simpler, but loses good data too. It is acceptable only if the damage is recent and widespread.
Slow or silent corruption. A bug has been writing subtly wrong values for days, or a storage fault has been corrupting blocks. The first job is to find the start of the damage. It may predate your shortest retention tier, which is why retention must cover realistic detection delays. Recovery is usually a repair forward. Compute the correct values from an older backup, or from source events, and apply corrections to production, rather than rolling back days of valid activity. Checksums at the application level help to detect this kind of damage early: periodic comparisons between replicas, and invariant checks such as balances that must sum to zero. Storage-level checksums (ZFS, and database page checksums) detect bit-level corruption.
Compromise. Ransomware, a malicious insider, or a stolen administrator credential. The environment itself can't be trusted, so recovery requires a clean environment and backups the attacker couldn't alter. This is covered in the ransomware deep dive below.
Loss of a dependency. Your service is fine, but a SaaS dependency is down or has lost data: an identity provider, a payment provider, a source-code host. This is often forgotten. Your DR plan should state what you do: run in degraded mode, fail over to a second provider, or wait. It should also say which of your data lives only in the dependency. Code hosting, ticketing and documentation SaaS platforms are frequent examples. If you can't operate without them, export their data regularly.
Loss of people or knowledge. A key team is unavailable during a crisis. It sounds soft, but it is real, and runbooks, cross-training and rotation of drill participants are the mitigation.
The important design check is that each scenario has a mechanism that reaches it:
- regional loss → cross-region copies;
- logical damage → PITR within retention;
- slow corruption → retention longer than detection;
- compromise → immutable, isolated backups;
- dependency loss → exports or a second provider.
A plan that buys an expensive active-active setup while keeping only 7 days of PITR protects well against the rarest scenario, and poorly against the most common ones.
Testing DR#
A DR plan that hasn't been tested is a hypothesis. In practice, untested plans fail in the same predictable ways:
- backups that silently stopped running months ago;
- backups that run but can't be restored (missing encryption keys, an incompatible version, an incomplete set of files);
- restores that work but take ten times longer than the RTO;
- runbooks that reference systems, people or credentials that no longer exist;
- dependencies nobody listed.
Testing turns each of these from a disaster-day surprise into a ticket.
DR tests form a ladder, from cheap and safe to expensive and realistic.
- Backup monitoring. Alert on backup failures. Also alert on backups that are missing (no successful backup in 26 hours), and on unexpected size changes. A backup that is suddenly 90% smaller is a red flag.
- Automated restore verification. On a schedule, restore the latest backup into an isolated environment, start the database and run checks: row counts against production, checksums of key tables, application-level queries. Do it at least weekly for critical stores, and some organisations do it daily. This is the single most valuable DR practice, because it continuously proves the RPO and measures the restore time.
- Tabletop exercise. The team walks through a disaster scenario on paper. "The primary region is gone. What do we do first? Who decides? Where is the runbook? Who calls the payment provider?" It's cheap, it finds gaps in process and ownership, and it should involve non-engineering stakeholders too.
- Component failover test. Fail over one service or database to the DR region, in a maintenance window or in production at low traffic, and measure the real RTO and RPO.
- Full DR drill. Fail over the whole service to the DR site, run on it for a period (hours or days), then fail back. It is expensive and risky, but it is the only test that proves the whole plan. It is often required annually by regulators in finance and healthcare.
- Continuous verification. Run the DR site as part of normal operation: serve some traffic from the warm standby, rotate the primary between regions periodically, or run active-active. The recovery path stops being special.
Testing DR, in depth: what a good test measures and finds#
Define pass criteria before the test. For example: "Restore the orders database from backups to a state no older than 15 minutes before the simulated failure (RPO), with the checkout service serving traffic within 60 minutes (RTO), and with zero integrity-check failures." Record the actual times for each phase. These become the honest RPO and RTO in the DR plan.
Check data correctness, not just that the database starts. Corrupt or incomplete restores often start fine. Useful checks:
- row counts and maximum IDs, compared with production at the target time;
- checksums of critical tables, or sampled rows;
- foreign-key and invariant checks: every order has a customer, ledger balances sum to zero;
- application smoke tests, such as logging in, placing an order and reading history.
Test restoring at realistic scale. Restoring a 10 GB staging database says little about a 10 TB production one. If production can't be restored in full routinely, at least restore a large representative subset, and extrapolate the throughput.
Test the selective restore. Many real recoveries are not "restore everything". They are "restore table X as of Tuesday 09:00 and merge the missing rows into production". Practise extracting data from a PITR restore and reconciling it into a live system, because that is the procedure you will need after most logical errors.
Rotate the people. If only one engineer has ever run the restore, the test proved that engineer can do it. Have different people execute the runbook, ideally ones who didn't write it. Every question they ask is a gap in the runbook.
Inject the realistic complications:
- the primary engineer is unreachable;
- the SSO provider is down, so break-glass credentials are needed;
- the newest backup is the one that's corrupt, so you must fall back to an older one;
- the restore has to start while the old site is still partially alive.
Track findings to closure. Every drill produces a list: missing permissions, an outdated image, a quota limit, an undocumented step. A drill whose findings aren't fixed before the next one is theatre.
A sensible cadence:
- backup monitoring: continuous;
- restore verification: daily to weekly per critical store;
- tabletop exercises: quarterly;
- component failovers: quarterly or after major changes;
- full drills: at least annually for tier 0 and tier 1 systems.
Re-test after big changes too: a database upgrade, a new region, a new encryption scheme, or a new backup tool.
Cost vs recovery time#
DR spending buys down RPO and RTO, with sharply diminishing returns. Moving from "restore in 2 days" to "restore in 4 hours" might mean scripting the environment and keeping backups nearby, which is cheap. Moving from 4 hours to 15 minutes needs a warm standby, roughly a fraction of production's cost running all the time. Moving from 15 minutes to near zero means active-active, which costs at least as much again as production, plus the engineering of multi-region data. RPO follows a similar curve, from nightly backups to log archiving to async replication to synchronous or consensus writes.
The rational choice compares expected loss with standing cost.
- Expected annual loss ≈ Σ over disaster types of (annual probability × cost of that disaster under this strategy).
- The cost of a disaster = cost per hour of downtime × achieved RTO + cost of losing data × achieved RPO + fixed costs (reputation, regulatory penalties, customer churn).
- Standing cost = DR infrastructure + replication transfer + storage + the engineering and testing time.
Pick the strategy that minimises the sum, then sanity-check against non-negotiable requirements, such as a regulator's mandated RTO, or contractual SLAs.
Because objectives are set per tier, a typical company runs several strategies at once:
- active-active or warm standby for payments and login;
- pilot light for the main product;
- backup-and-restore for internal tools and analytics.
Tiering is where most of the savings come from.
Cost vs recovery time, in depth: a worked comparison#
Take an online retailer with the following numbers:
- revenue that stops during an outage: about $50,000 per hour;
- lost orders (data loss): about $30,000 per hour of lost data, including refunds, support work and goodwill;
- production infrastructure: $100,000 a month;
- probability of a regional disaster requiring DR invocation: assume about 2% a year.
That last figure is illustrative. Real figures are hard to estimate, which is itself an argument for modest, well-tested DR rather than an elaborate untested one.
| Strategy | Achieved RTO / RPO | Loss per disaster | Expected annual loss (× 0.02) | Annual standing cost (approx.) |
|---|---|---|---|---|
| Backup and restore | 24 h / 1 h | 24 × 50k + 1 × 30k = $1.23M | $24.6k | $30k (storage, transfer, tests) |
| Pilot light | 2 h / 1 min | 2 × 50k + small = $100k | $2k | $150k (DB replica, storage) |
| Warm standby | 20 min / seconds | about $17k | $0.3k | $350k (stack at about 25%) |
| Active-active | about 1 min / about 0 | about $1k | negligible | $1.2M+ (second full stack plus engineering) |
On these numbers, plain expected-value arithmetic favours backup-and-restore. Each rung costs far more than the expected loss it saves. The arithmetic ignores several things:
- Tail risk. A 24-hour outage might cost far more than linear revenue: customers who leave for good, a news cycle, contractual penalties. If a long outage would be existential, buy down the tail regardless of the expected value. This is insurance logic.
- Smaller events. The same DR machinery also helps with more frequent events: a corrupted database, a failed migration, a long single-region outage.
- Shared value. A warm standby can double as a staging-at-scale environment, or serve read traffic nearby, which offsets its cost.
- Regulatory floors. Some sectors mandate specific RTOs.
The usual outcome is tiering. In this example:
- pilot light for order capture and payments;
- backup-and-restore with good automation for the catalogue (which can be regenerated) and for internal systems;
- active-active only if the business is global and downtime is reputationally existential.
The worked example also shows that automation is the cheapest RTO reduction. A backup-and-restore strategy with infrastructure-as-code, parallel restores and a rehearsed runbook might achieve 4 hours instead of 24. That cuts the expected loss by more than 80%, for engineering time rather than standing infrastructure.
When to Use It#
Every system that stores data needs some DR: at minimum, backups that are off-site, immutable and tested. Go further when:
- The business impact analysis demands it: downtime cost per hour, or data-loss cost, makes the standing cost of a stronger strategy cheaper than the expected or tail loss.
- Regulation or contracts set objectives: for example, financial services operational-resilience rules, healthcare data rules, or customer SLAs with stated RTO and RPO.
- Data is irreplaceable: user-generated content, financial records, medical records. Strong backup and retention are needed here even if the RTO can be long.
- Ransomware or insider threat is part of your risk model, which it is for most organisations. Immutable, isolated backups are needed regardless of the RTO.
- You depend on one region or one provider for revenue-critical systems. Pilot light or warm standby is worth considering for the critical tier.
When NOT to Use It#
- Expensive DR for data that can be regenerated. Caches, search indexes, derived analytics tables and build artefacts can usually be rebuilt from the source of truth. Back up the source, and document the rebuild time, instead of replicating every derived store.
- Active-active or warm standby for low-tier systems. An internal wiki doesn't need a 15-minute RTO. Tier the objectives.
- Replacing HA with DR. DR invocation is slow and lossy. Ordinary server and zone failures should be handled by HA without ever touching the DR plan.
- Elaborate untested plans. A simple, regularly tested backup-and-restore beats an ambitious warm-standby design that has never been failed over. Prefer the strategy you can afford to test.
- Treating replication as a backup. A replica is HA, not DR. It faithfully copies deletes and corruption. Keep point-in-time backups as well.
How to Implement It#
- Run a business impact analysis. List services and data stores. For each one, estimate the cost of downtime and of data loss, and assign a tier with an RPO and RTO. Get the business to sign off on the numbers.
- Map dependencies. For each tier 0 or tier 1 service, list everything it needs to run: data stores, identity, secrets, DNS, third parties, CI/CD and images. A service's real RTO is bounded by its slowest-to-recover dependency.
- Choose a strategy per tier. Use backup-and-restore, pilot light, warm standby or active-active, using the cost comparison above and any regulatory floors.
- Implement backups:
- physical backups plus continuous log archiving (PITR) for databases;
- versioning plus cross-region and cross-account replication for object storage;
- snapshots copied off-region for block volumes;
- Git for infrastructure and configuration.
- Isolate the backups:
- store them in a separate account or project, with separate credentials;
- make them immutable (Object Lock or Vault Lock) for the retention window;
- encrypt them with keys that are themselves protected from deletion;
- alert on any policy change.
- Build the recovery environment to match the strategy. It should be fully defined in infrastructure-as-code, with images kept current, quotas raised or capacity reserved in the DR region, and network paths and partner allow-lists pre-arranged.
- Write the runbooks: invocation criteria, roles, step-by-step failover, verification, communications and failback. Store copies outside the primary environment.
- Automate restore verification, and alert on backup freshness and size anomalies.
- Test on a cadence: tabletop, component failover and full drill. Record the measured RTO and RPO, and fix the findings.
- Review after every significant change, and at least annually: new services, data growth (which lengthens restore times), new regulations.
As a concrete example, here is a PostgreSQL setup using pgBackRest. It takes weekly full backups and daily incrementals, archives the WAL continuously and asynchronously to an encrypted S3 bucket in another region, and can restore to any second within the retention window.
# /etc/pgbackrest/pgbackrest.conf
[global]
repo1-type=s3
repo1-s3-bucket=acme-orders-backups-dr # bucket in a separate DR account
repo1-s3-region=eu-west-1
repo1-s3-endpoint=s3.eu-west-1.amazonaws.com
repo1-path=/orders
repo1-retention-full=5 # keep 5 full backups plus their WAL
repo1-cipher-type=aes-256-cbc # passphrase supplied from a secret store
archive-async=y # ship WAL in the background
process-max=8 # parallel compression and transfer
compress-type=zst
[orders]
pg1-path=/var/lib/postgresql/16/main
# postgresql.conf
# archive_mode = on
# archive_command = 'pgbackrest --stanza=orders archive-push %p'
# archive_timeout = 60 # bound the RPO on quiet periods
# Schedule: weekly pgbackrest --stanza=orders --type=full backup
# daily pgbackrest --stanza=orders --type=incr backup
# PITR to one second before a bad migration:
# pgbackrest --stanza=orders --type=time \
# --target="2026-03-10 14:32:10+00" --target-action=promote restorePair this with a scheduled job that restores the latest backup into a scratch instance, runs integrity queries, and reports the elapsed time. That makes the measured RTO a metric on a dashboard.
| Technology | Fits when |
|---|---|
| Managed database PITR and cross-region replicas (RDS / Aurora, Cloud SQL, Azure SQL, DynamoDB PITR and global tables) | Managed databases; the easiest route to PITR and pilot light |
| pgBackRest, WAL-G, Barman (PostgreSQL); Percona XtraBackup plus binlog (MySQL) | Self-managed databases needing physical backups, PITR and parallel restore |
| AWS Backup (with Vault Lock), Azure Backup, Google Cloud Backup and DR | Central policy-driven backups across many resources, with immutability |
| S3 / GCS / Azure Blob versioning, cross-region replication, Object Lock / retention locks | Object data DR and immutable backup storage |
| AWS Elastic Disaster Recovery, Azure Site Recovery, Zerto | Block-level continuous replication of servers or VMs into a DR site (lift-and-shift workloads) |
| Velero | Backing up Kubernetes resources and persistent volumes |
| Restic, BorgBackup, Kopia | Deduplicated, encrypted file-level backups to object storage |
| Veeam, Commvault, Rubrik, Cohesity | Enterprise backup across on-premises and cloud, with catalogues and immutability |
| Terraform / OpenTofu, CloudFormation, Pulumi, plus GitOps (Argo CD, Flux) | Rebuilding infrastructure and deployments in the DR region from code |
Trade-offs#
| Option | Pros | Cons | Pick when |
|---|---|---|---|
| Backup and restore | Cheapest; simple; protects against logical damage with PITR | Long RTO; restore time grows with data size | Tier 2 and 3; small data; tolerant users |
| Pilot light | Low RPO; data is always ready; modest cost | RTO depends on provisioning compute, which can be slow in a regional event | Tier 1 with an RTO of an hour or more |
| Warm standby | RTO in minutes; environment proven to run | Ongoing cost; standby must be kept in sync with production changes | Tier 0 and 1 with RTO under about 30 minutes |
| Multi-site active-active | RTO near zero; no "invocation" step; capacity always proven | Highest cost; multi-region data complexity; still needs backups for logical damage | Global, mission-critical services |
| Full vs incremental backups | Fulls restore fast; incrementals are cheap to take | Fulls are costly to store and take; incremental chains are fragile and slower to restore | Mix: periodic fulls plus incrementals (or incremental-forever with synthetic fulls) |
| Logical vs physical backups | Logical: portable, single-table restores | Logical: slow at scale; no PITR | Physical plus PITR for DR; logical exports for portability and compliance |
| Long vs short retention | Long: survives late-detected corruption, meets compliance | Long: storage cost; privacy (erasure) obligations | Retention set by detection delay plus legal requirements |
Common Pitfalls#
- Replication treated as backup. Replicas copy the
DROP TABLEtoo. - Backups never restored. The first restore attempt happens during the disaster, and fails.
- Backups in the same blast radius: same region, same account, same credentials, or the same storage array as production.
- Missing pieces: encryption keys, secrets, DNS, infrastructure code, container images or configuration not backed up, so data can be restored but the service can't.
- RTO computed on paper. Restore throughput, log replay and DR-region quotas were never measured.
- No failback plan, so the team is stranded in the DR region, or loses data moving back.
- Runbooks inside the failed system: the wiki, the SSO, or the chat tool that is down with it.
- Silent backup failures: jobs that report success while producing empty or partial output. Monitor size and verify by restoring.
- One person knows the procedure. Their absence becomes part of the disaster.
- Retention shorter than detection time, so every restorable backup already contains the corruption.
Real-World Examples#
- GitLab (2017). After the accidental deletion of the primary database's data directory, GitLab's public postmortem described a series of protective mechanisms that turned out not to be working. Among them, its regular database dumps to S3 were failing, and the failure notifications weren't being received. The eventual restore came from a snapshot made about six hours earlier for staging. The follow-up work centred on monitoring backups and testing restores.
- OVHcloud (2021). The Strasbourg fire destroyed the SBG2 data centre. Customers who had backups only within the same site, sometimes using backup options located in the same campus, lost data. The event is the standard illustration of why "off-site" must mean outside the physical blast radius.
- Maersk (2017). The NotPetya malware destroyed a large part of Maersk's IT systems, including its Windows domain controllers. Widely reported accounts describe the recovery of its identity infrastructure from a domain controller in Ghana that happened to be offline during the attack because of a power outage. It's a vivid lesson that identity systems need offline, isolated backups.
- Code Spaces (2014). An attacker with access to the company's AWS console deleted its infrastructure and backups, which lived in the same account. The company ceased operations. Separate accounts and immutable backups are the direct remedy.
Case studies that use this pattern#
- Design a Payment System: tier 0 ledger with zero RPO, PITR, and reconciliation after restore.
- Design Object Storage (S3): durability through erasure coding versus DR through versioning and cross-region copies.
- Design a File Sync Service (Dropbox): version history as user-facing recovery, plus backend DR.
- Design a Distributed Message Queue (Kafka): cross-cluster mirroring and the RPO of a replicated log.
In the Interview#
Deep Dive: Ransomware-resilient backupsShow
Ransomware changed what backups must withstand. Modern attacks don't just encrypt production. Attackers commonly spend days or weeks inside a network first, escalating privileges, finding the backup systems and destroying or encrypting the backups before triggering the visible attack. A backup design is only ransomware-resilient if it survives an attacker who holds the production administrators' credentials.
Threat model. Assume the attacker can do whatever a production admin can:
- delete snapshots;
- change bucket policies;
- shorten retention;
- schedule key deletion in the key management service;
- delete the backup server's catalogue.
The design goal is that none of these actions can destroy the recovery copies within the retention window.
Isolation layers:
- A separate security domain. Keep backups in a dedicated account, project or subscription. Grant production write-only access: it can push backups but not delete them. Administration of that domain uses different identities, ideally with hardware-key MFA, and with no standing access from production.
- Immutability with a lock that admins can't lift. S3 Object Lock in compliance mode (governance mode can be bypassed with special permissions), AWS Backup Vault Lock in compliance mode, locked GCS retention policies and Azure immutable storage with locked policies all refuse deletion until the retention date, even for the account root. This is the central control.
- Protected keys. If backups are encrypted with a KMS key that the attacker schedules for deletion, they become unreadable once deletion completes. Mitigations: key policies that deny deletion to production roles, the mandatory waiting period on key deletion (AWS KMS requires 7–30 days) combined with alerts on
ScheduleKeyDeletion, and keys held in the isolated backup account. - An offline or air-gapped copy for the most critical data. Tape or offline media is still used for this. A logical air gap, an isolated account with no network path or trust relationship to production, is the cloud equivalent.
Detection. Watch for the precursors:
- backup jobs failing or shrinking;
- sudden spikes in changed data. Encryption rewrites everything, so incremental backups suddenly become as large as fulls;
- deletions of snapshots, and changes to retention policies or Object Lock settings.
Some backup products use change-rate anomalies as an early ransomware signal.
Clean-room recovery. Restoring into the same compromised environment can reinfect you, or restore the attacker's persistence mechanisms. A mature plan restores into a clean, isolated environment, built from known-good infrastructure-as-code and images. It scans the restored data and binaries, and rebuilds the identity infrastructure (directory services, SSO) from trusted sources first. Restore points must also predate the intrusion, not just the encryption event. That is another reason for long retention.
Recovery priorities. In a large compromise, you can't restore everything at once. Restore bandwidth, people and verification capacity are limited. Pre-agree the order:
- identity and access;
- core networking and DNS;
- secrets;
- tier 0 data and services;
- everything else.
The Maersk recovery shows why identity comes first. Without it, nothing else can be administered.
Deep Dive: Restoring a distributed system to a consistent pointShow
A monolith with one database restores to one consistent moment. A microservice system with fifteen databases, a Kafka cluster, a search index and caches doesn't. Each store's backups were taken at different times, and each will restore to a slightly different point. After recovery, the order service may know about order 1234 while the payment service has no record of its payment. Or the payment exists but the order doesn't.
The theory. A consistent global snapshot of a distributed system is a set of per-process states in which every message recorded as received was also recorded as sent. Chandy and Lamport's "Distributed Snapshots: Determining Global States of Distributed Systems" (ACM TOCS, 1985) showed how to capture one without stopping the system: send markers along every channel, and record state as the markers arrive. Production systems rarely run Chandy–Lamport across their databases. But the definition explains the problem: independent backups are not a consistent cut, and the restored system can contain effects without causes.
Practical approaches, from simplest to strongest:
- Restore everything to the same wall-clock time with PITR. If every database supports PITR and their clocks are well synchronised (NTP or PTP, with error under a few milliseconds), restoring all of them to 14:30:00.000 gives a cut that is consistent up to clock error and in-flight messages. Anything that straddled the cut, sent by one service before 14:30 but processed by another after it, is inconsistent. This is simple and usually good enough, if combined with reconciliation.
- Reconciliation after restore. Design services so that cross-service inconsistencies are detectable and repairable:
- every cross-service action has an ID, such as an order ID or idempotency key;
- each service can list its recent actions;
- a reconciliation job compares the lists and re-drives or compensates the mismatches. Payment systems already do this daily with their providers, so DR reuses the same machinery.
- Idempotent consumers make re-driving safe. See Idempotency.
- The log as source of truth. If services are built on an event log, as in event sourcing or the outbox pattern, recover the log to a point, then rebuild each service's state by replaying from its last snapshot. The log's order defines a consistent cut automatically. The cost is replay time, and the need to back up the log itself, for example Kafka with tiered storage or mirrored clusters. See Event Sourcing and CQRS.
- Single-database transactions for tightly coupled data. Where two pieces of data must never disagree, such as an order and its ledger entries, keeping them in one database makes them restore together, which settles the question.
Kafka and consumer offsets. Restoring a Kafka cluster from a mirror (MirrorMaker 2, Confluent Cluster Linking) raises the question of where consumers resume. Offsets differ between clusters. MirrorMaker 2 translates committed consumer-group offsets through offset-sync records, so consumers can resume close to where they were in the source cluster. They resume "close" rather than exactly, so consumers must tolerate duplicates, which is at-least-once delivery. Their effects must therefore be idempotent. See Delivery Semantics.
Derived stores. Search indexes, caches, materialised views and analytics copies don't need their own consistent backups if they can be rebuilt from the sources of truth after restore. The plan must state how long each rebuild takes. A 2-billion-document search index might take many hours to reindex, which might break the RTO for search. If it does, back up the index too, through Elasticsearch snapshots to object storage, and accept a catch-up period after restoring it.
External side effects. Emails sent, payments captured with providers and messages delivered to partners can't be rolled back by a restore. After restoring to 14:30, the system may re-send the emails it sent between 14:30 and the disaster, or forget charges that the provider did capture. Mitigations:
- send external effects through an outbox, with deduplication IDs that the external system honours, such as payment-provider idempotency keys;
- reconcile against provider records after restore;
- suppress replays of notifications older than a threshold.
Deep Dive: Backups at scale, from deduplication to parallel restoreShow
At petabyte scale, the naïve backup model of nightly fulls breaks on every axis: time, storage, network and restore speed.
Incremental-forever with synthetic fulls. Instead of periodic real full backups, which read the whole data set from production, take one initial full and then only incrementals forever. A long chain of incrementals is slow to restore, and fragile: one bad link breaks everything after it. So the backup system builds synthetic full backups inside the backup storage, by merging the last full with subsequent incrementals. Production pays only for incrementals. Restores read a recent synthetic full plus a few incrementals. Many enterprise backup products and pgBackRest-style tools work this way, or offer it as an option.
Deduplication. Backup data is highly redundant. Successive backups of the same volume share most of their blocks, and many VMs share operating-system images. Content-addressed backup stores split data into chunks, hash each one (SHA-256, BLAKE3) and store each unique chunk once. Each backup is a manifest listing its chunk hashes. Content-defined chunking (Rabin fingerprints, FastCDC) keeps chunk boundaries stable when data is inserted or shifted, so a small edit changes only a few chunks. Restic, Borg and Kopia use this design. For repetitive data, dedup ratios of 10:1 to 50:1 are common in practice. Unique, already-compressed or encrypted data dedups poorly. The Handling Large Blobs page covers chunking algorithms.
The cost of deduplication is that a single corrupted chunk can affect every backup that references it. Verification and redundancy of the backup store itself matter more, not less. Periodically re-read and re-hash chunks (a "scrub"), and keep a second, independent copy of the repository.
Encryption versus dedup. Encrypting data before it reaches the backup system destroys dedup, because identical blocks encrypt to different ciphertexts. Backup systems therefore usually chunk and dedup first, then encrypt each chunk with keys held by the backup system. Convergent encryption, where a chunk's key is derived from its content, keeps dedup across encrypted data but leaks equality: an attacker can tell whether two backups contain the same chunk.
Parallel restore is the RTO lever. Restore throughput is the binding constraint for backup-and-restore and pilot-light strategies. Parallelise across:
- files and chunks: many concurrent object-store GETs. Object stores scale with parallelism, and per-request throughput is limited, so 32–256 concurrent streams are normal;
- shards: a sharded database restores each shard independently, in parallel, onto separate machines. Restoring 100 shards of 100 GB each in parallel takes roughly as long as restoring one 100 GB shard, provided you have the machines.
- lazy loading: restore metadata first and serve reads by fetching data on demand, as cloud volumes do when created from snapshots, while a background process hydrates the rest. Service resumes before the restore finishes, at reduced performance.
Here is a worked comparison for a 50 TB data set:
| Approach | Throughput | Restore time |
|---|---|---|
| Single stream at 200 MB/s | 0.2 GB/s | 250,000 s ≈ 69 hours |
| 32 parallel streams on one big restore host, limited by its 25 Gbit/s NIC (about 3 GB/s) | about 3 GB/s | about 4.6 hours |
| 50 shards restored onto 50 hosts, each at about 1 GB/s | about 50 GB/s | about 17 minutes, plus log replay and verification |
| Snapshot-based lazy volumes | Immediate availability, degraded performance | Minutes to usable; hours to fully warm |
The lesson for DR design: size the restore path, not just the backup path. Backup systems are often tuned for the nightly window and never tested for restore speed. Choose data layouts (sharding, per-tenant backups) that allow parallel restores. Also keep the most critical data in units small enough to restore well within the RTO, and restore those first.
Restore priority within a data set. Not all data is needed at once. A system can bring up recent data first (the last 30 days of orders) and backfill history afterwards, if the application tolerates temporarily incomplete history and shows it honestly. Tiered restores like this can cut the effective RTO for users by an order of magnitude.
Key Takeaways#
- HA handles expected failures with live redundancy. DR handles what HA can't: regional loss, deletion, corruption and ransomware, which replication would faithfully copy.
- RPO is the data you can afford to lose, set by how often and how far you copy data. RTO is the downtime you can afford, set by standing infrastructure and automation. Set both per service tier, from a business impact analysis.
- Use full, incremental and differential backups and snapshots for history, and point-in-time recovery (base backup plus log replay) to recover to the moment before a bad write.
- Keep backups off-site, in a separate account with separate credentials, immutable for the retention window, and encrypted with protected keys. Follow 3-2-1, plus an immutable copy and zero restore errors.
- The four DR strategies (backup and restore, pilot light, warm standby, multi-site active-active) trade standing cost for faster recovery. Choose per tier, and remember that automation is the cheapest way to cut the RTO.
- Compute the RTO honestly: data size ÷ restore throughput, plus log replay, provisioning, verification and traffic shift. Then measure it in drills.
- Untested backups are hypotheses. Automate restore verification, and run tabletops, component failovers and full drills, including failback, on a schedule.
- In distributed systems, restore to a common point in time, then reconcile across services with idempotent re-drives. Rebuild derived stores from the sources of truth.