SDSystem DesignConcepts to case studies
System DesignDSA
x
0/311
Part 1: Foundations
Part 2: APIs and Communication
Part 3: Caching
Part 4: Data and Storage
  • Indexing
  • Partitioning
  • Replication
  • Sharding
  • Query Optimization
  • Denormalization
  • Materialized Views
  • Connection Pooling
  • Replication Models
  • Replication Lag
  • Quorum (R + W > N)
  • Shard Keys, Hot Shards and Resharding
  • Cross-Shard Joins
  • Backups, RPO, RTO and Disaster Recovery
  • Point-in-Time Recovery
  • Data Archiving and TTL
Part 5: Architecture
Part 6: Distributed Systems
Part 7: Advanced Data Topics
Part 8: Operations and Security
Part 9: Estimation and Interview Method
Part 10: Case Studies
System Design/Data and Storage/Database Scaling

Backups, RPO, RTO and Disaster Recovery

How much data can you lose, how long can you be down, and how to plan for a whole region failing.

⏱ 15 min readIntermediateMust KnowInterview FavouriteHas visualizer
SummaryConceptReal-Life ExampleWhy?Where?How It WorksStepsKey TermsPros & ConsMistakesReal WorldRead NextInterview Q&ACheat-Sheet

01Quick Summary

Backups are copies of your data you can restore after a disaster. RPO and RTO are the two promises that tell you how good those backups must be. Disaster recovery (DR) is the plan for getting back to work.

  • RPO (recovery point objective): how much recent data you can afford to lose, measured in time.
  • RTO (recovery time objective): how long you can be down before it hurts too much.
  • Tighter targets cost more money. And replication is not a backup: a bad delete is copied to every replica within moments.

02Concept: What is it?

Hardware fails, people make mistakes, software has bugs, and whole data centres can lose power or flood. Replicas protect you against a single machine dying. They do not protect you when someone runs DELETE without a WHERE, when a bug writes garbage, or when ransomware encrypts everything, because every replica faithfully copies the damage.

A backup is a separate, older copy that the damage did not reach. Two numbers describe how good your plan is:

RPO and RTO on a timeline
💾Last good copybackup or log
→↓RPO: data lost
💥Disaster
→↓RTO: time down
✅Back in service
Data written in this gap is lost Users cannot use the system
RPO looks backwards from the disaster. RTO looks forwards.
🧠An untested backup is not a backup
Many teams find out that a backup is empty, corrupt, too old or impossible to restore on the day they need it. Restore regularly, on purpose, and time it. The time you measure is your real RTO.

03Real-Life Example

🍵The Shop Photocopier
A small shop keeps its customer book in a drawer. Every night the owner photocopies the new pages and takes the copy home. If a fire burns the shop at 3 pm, the owner loses everything written since last night (that is the RPO: about a day). Then it takes a week to find a new shop, buy new shelves and copy the book back (that is the RTO). A bigger shop might copy every page as it is written to a second shop across town (a much smaller loss, a much faster return, and a much bigger bill). But if a clerk scribbles over a page, both copies show the scribble, so the shop still needs old copies kept apart.
Shop
Backup and disaster recovery
The nightly photocopy
A backup
Pages written since the last copy
The data you lose (RPO)
Time to open a new shop
Recovery time (RTO)
Copying each page as it is written
Log shipping or continuous replication
A second shop already staffed and open
Warm standby or active-active
A scribble copied to both shops
A bad delete that replicates
Copy kept at the owner's home
An off-site, separate copy
Replication vs backup
Replication
🗄️Primary
→↓DELETE copied
🗄️Replica
Protects against one machine dying
Protects against a bad delete
Backup
🗄️Database
📦Backup from 02:00
Protects against a bad deleteup to the backup time
Protects against a lost region (if off-site)
Replication copies mistakes quickly. A backup keeps an older, clean point.

04Why Do We Need It?

🧯Survive mistakes
Humans delete the wrong thing. Backups let you go back to before the mistake.
🛡️Survive attacks
Offline or immutable copies cannot be encrypted by ransomware that reached production.
🌍Survive big failures
A region or data-centre loss needs a copy and a plan outside that place.
📜Meet rules
Many industries require backups, retention periods and proof that restores work.
🎯Make promises you can keep
RPO and RTO turn a vague wish ('be safe') into numbers you can test and pay for.
💸Spend the right amount
Not every system needs a hot second region. Targets tell you what each one is worth.
Decide how much data you can lose and how long you can be down, per system. Then pay for exactly that, and prove it by restoring.

05Where Do We Use It?

💳Payments and banking
Very small RPO (close to zero) and short RTO. Often multi-region with synchronous copies.
🛒E-commerce
Orders matter most. Product pages can be rebuilt. Different parts get different targets.
📧Internal tools
A day of lost data and a few hours down may be fine. Simple nightly backups can be enough.
🏥Healthcare and public sector
Strict retention and recovery rules, and audits that ask for restore proof.
☁️Cloud databases
Automated snapshots and log archiving are built in. You choose retention and test restores.
📱SaaS products
Tenant-level restore requests (restore one customer) are common and need planning.

06Types / Parts / How It Works

Kinds of backup

KindWhat it copiesRestore needsNotes
FullEverythingThat one copyBiggest and slowest to take, simplest to restore
IncrementalOnly what changed since the last backup of any kindThe last full plus every incremental after it, in orderSmall and fast to take, longer restore chain
DifferentialEverything changed since the last full backupThe last full plus the latest differentialGrows each day, but restore uses just two pieces
SnapshotA storage-level point-in-time image of a disk or volumeThe snapshotVery fast to take. Check that it is consistent for a database
Logical dumpRows exported as SQL or filesRe-import the dataPortable across versions, but slow to restore at large sizes
Log archiveThe write-ahead log, shipped continuouslyA base backup plus the logsLets you rewind to a chosen moment

Disaster recovery strategies, from cheapest to fastest

StrategyWhat runs in the second regionRecoveryCost
Backup and restoreNothing. Only backup copies are stored thereSlowest: build everything, then restore$
Pilot lightThe database copy, kept up to date. Other servers are offFaster: start and scale up the rest$$
Warm standbyA small but complete copy of the system, runningFast: scale it up and switch$$$
Active-activeA full system in each region, both serving usersFastest: reroute traffic$$$$
Choosing by your targets
🐢Hours of loss, a day downbackup and restore
→↓tighter
🚶Minutes of loss, under an hourpilot light / warm
→↓tighter
🏃Near zero loss, minutes downactive-active
Illustrative: smaller targets push you right and to a higher price.
VisualizerHow much data do you lose, and how long are you down?Change the backup interval, turn log archiving on and off, and try each strategy. Then pick the 'bad delete' disaster and see why a second region does not help.
What went wrong?
DR strategy
Data lost (RPO)
18 h
target 15 min: FAIL
Time down (RTO)
2 h 45 min
target 2 h: FAIL
Restore alone
2 h
1000 GB at 500 GB/h
Build the second region from nothing, restore the backup, replay the logs.
All four strategies for this disaster (bar = time down, price is illustrative):
Backup and restore $
lose 18 h · down 2 h 45 min ✗
Pilot light $$
lose under 1 min · down 30 min ✓
Warm standby $$$
lose under 1 min · down 10 min ✓
Active-active $$$$
lose under 1 min · down 2 min ✓
Both targets missed: you would lose 18 h of data (target 15 min) and be down for 2 h 45 min (target 2 h). Pay for a faster strategy, or loosen the promise you made.

Every figure here is made up for teaching: 45 min to prepare a new region, 30 / 10 / 2 min to take over, a log shipped about every 5 min, log replay at about 10% of the time it covers, and 15 min to notice a bad delete. Without log archiving, the data you lose is the time since the last backup. Real times depend on your tools, and only a practised restore tells you the truth.

07How to Use It / Steps / Implementation

Making a recovery plan

  1. 1
    Set targets per system
    Ask the business: how much data can we lose, and how long can we be down? Write an RPO and an RTO for each service, not one for everything.
  2. 2
    Match the backup to the RPO
    If the RPO is one hour, a nightly backup is not enough. Add log archiving or more frequent snapshots so the gap is under an hour.
  3. 3
    Match the strategy to the RTO
    Restoring a large database from storage can take hours. If the RTO is shorter than that, keep a running standby.
  4. 4
    Keep copies apart
    Store backups in another account, another region, and ideally in a form that cannot be changed or deleted for a set time (immutable).
  5. 5
    Encrypt and control access
    Backups hold all your data. Encrypt them, restrict who can read or delete them, and keep the keys safe, separate from the data.
  6. 6
    Practice restores
    Restore to a test environment on a schedule. Time it, check the data, and fix the runbook. Run a full failover drill at least once a year.
  7. 7
    Set retention and delete on purpose
    Keep what rules require, and expire the rest. Old backups cost money and can hold data you should have deleted.
💡The 3-2-1 idea
A common rule of thumb: keep 3 copies of your data, on 2 different kinds of storage, with 1 copy off-site. It is a starting point, not a guarantee. Add immutability and tested restores on top.
⚠️Restore time grows with size
The time to restore is roughly the data size divided by the restore speed, plus time to replay logs and to bring services back. A database that grew tenfold has a tenfold slower restore, even if the backup job still "succeeds".

08Key Terms to Know

TermMeaning in easy words
BackupA separate copy of data that can be restored after a loss
RPORecovery point objective: the most recent data you can afford to lose, in time
RTORecovery time objective: the longest you can be down
Disaster recovery (DR)The plan and setup for restoring service after a major failure
Full / incremental / differentialThree ways to choose what a backup copies
SnapshotA fast point-in-time image of a disk or volume
Log archivingContinuously saving the database log, so you can replay changes after a backup
Pilot lightA DR setup with only the data layer running in the second region
Warm standbyA scaled-down but running copy of the whole system
Immutable backupA backup that cannot be changed or deleted until a set date
3-2-1 ruleThree copies, two kinds of storage, one off-site

09Pros, Cons and Trade-offs

✅ Pros
  • Protects against mistakes, attacks and disasters
  • Numbers (RPO and RTO) make the plan testable
  • Simple backups are cheap and easy
  • Standby setups cut downtime sharply
  • Immutable copies defeat many ransomware attacks
⚠️ Cons
  • Faster recovery costs a lot more
  • Backups can silently fail or be unusable
  • Restores get slower as data grows
  • Standby systems can drift from production
  • Backups hold sensitive data that needs protection too

Trade-offs

ChoiceWe gainWe lose
Backup more oftenSmaller data lossMore storage, more load during the backup
Archive the logRewind to almost any momentAnother thing to run, monitor and secure
Keep a running standbyShort recovery timeYou pay for idle capacity
Active-activeAlmost no downtimeComplex data conflicts, highest cost
Keep backups for yearsMeets rules, covers late discovery of damageStorage cost and larger legal exposure
Immutable, locked copiesSafe from deletion and ransomwareYou cannot remove them early, even by mistake

10Common Problems and Mistakes

Common mistakes

  1. Treating replication as a backup. A bad delete or corrupt write reaches every replica within seconds.
  2. Never testing a restore. The backup turns out to be empty, old, or missing a key piece.
  3. Backups in the same account or region. One mistake, one attacker or one disaster takes everything.
  4. Targets nobody agreed on. The RPO and RTO in the slide deck are not the ones the system can do.
  5. Forgetting the encryption keys. An encrypted backup is useless if the key was lost with the data centre.
  6. Ignoring everything outside the database. Config, secrets, DNS, queues and infrastructure code also need recovery.
  7. A standby that has drifted. It cannot take the load, or runs old code, when you finally need it.

Things to watch

⏱️Measured RTO
Time real restores and drills. Compare with the promise.
📏Backup age
Alert if the newest good backup or log segment is older than your RPO.
✅Restore checks
After a restore, run checks on the data, not just 'the process finished'.
🔐Access to backups
Limit and audit who can delete or read them.

11Real-World Examples

☁️Cloud snapshots
Managed databases take automated snapshots and can keep log archives for point-in-time recovery.
🧊Cold archive storage
Old backups move to cheap, slow storage tiers, which is fine until you must restore in a hurry.
🔒Object lock
Object stores can lock backup files so they cannot be deleted for a period.
🎭Game days
Teams rehearse a region loss on purpose, to find the gaps in the plan.
🏦Banks
Synchronous copies to a second site keep the data loss close to zero for the most critical systems.
🔄Cross-region replicas
Used for fast failover, together with backups for the 'bad delete' case.
📝Note
Features, limits and prices depend on your provider and version. Treat the numbers on this page as teaching examples and use your own tests.
Mini case: a bad deploy deletes a table
  1. 📦
    02:00
    Nightly backup completes
  2. ✍️
    10:00 to 14:00
    Normal writes, logs archived
  3. 💥
    14:05
    Bad deploy deletes the table
  4. ⏪
    14:20
    Noticed. Restore backup, replay logs to 14:04
  5. ✅
    15:30
    Back, with almost no data lost
Why log archiving beats the nightly backup alone.

12Related Topics to Read Next

Replication→

Protects against machine loss, but copies mistakes too.

Point-in-Time Recovery→

Rewind to the moment before the mistake using a backup plus logs.

Write-Ahead Log (WAL)→

The log that makes continuous archiving and replay possible.

Failover→

Switching to a standby, which is how short RTOs are met.

Availability→

RTO and the time to recover feed straight into your nines.

SLA, SLO and SLI→

RPO and RTO are promises, and belong in your objectives.

Object Storage→

The usual cheap, durable home for backup files.

13Interview Questions with Short Answers

14Quick Revision Cheat-Sheet

  • ✔RPO: how much data you can lose (time). RTO: how long you can be down.
  • ✔Replication ≠ backup. A bad delete replicates instantly.
  • ✔Backup only: worst-case loss = the backup interval. Add log archiving to shrink it.
  • ✔Types: full, incremental (full + all), differential (full + latest), snapshot, logical dump.
  • ✔DR ladder: backup and restore, pilot light, warm standby, active-active.
  • ✔Restore time: size / speed + log replay + bring-up. Measure it.
  • ✔Protect copies: off-site, separate account, immutable, encrypted. Follow 3-2-1.
  • ✔One line: “A backup you have not restored is a hope, not a plan.”
← Previous
Cross-Shard Joins
Next →
Point-in-Time Recovery