Reliability and security · L2Disaster recovery and backups

Disaster recovery and backups

Pick an RPO and an RTO, keep backups that a bad script cannot reach, and time real restores until you know you can get your data back.

L2 SeniorReliability and security18 min read
Fact-checked by AI against cited sources · Human review pendingLast reviewed 8 Nov 2026 · How we check content
Section 1 of 8

What broke

On 5 April 2022, a cleanup script at Atlassian deleted 883 sites. They belonged to 775 customers. 1 You met this outage in incident response, from the communication side. Here is the restore side.

Atlassian was not careless about backups. It kept them for 30 days. It could restore any data store to a chosen point in time. It also kept immutable backups and tested its restores. 1

The data did come back. For most customers, Atlassian restored to five minutes before the deletion. For 57 customers restored early, some databases first went back further, and Atlassian recovered the missing data later. It says no customer lost more than five minutes of data. 1

Time was the problem. The first customers got their sites back on 8 April. The last sites came back on 18 April. Some customers waited up to 14 days. 1

Why so slow? Atlassian regularly restored one customer or a small set of customers, and it could restore all customers into a new environment. It had no tested way to restore hundreds of sites into the live, shared environment. Each data store held data for many customers. So the team had to pull each deleted site out of the backups, piece by piece. With its first method, Atlassian estimated three weeks to restore everyone. 1

In its own words: "we missed our RTO but met our RPO". 1

Section 2 of 8

The idea in simple words

Disaster recovery (DR) is your plan to get data and service back after something big goes wrong. That can be a lost data centre, a bad script, or ransomware.

Two numbers set the goal. The RPO (recovery point objective) is how much data, measured in time, you accept to lose. The RTO (recovery time objective) is how long you accept to be down. Atlassian describes them with two questions. How fresh is the data after you restore it? How quickly can you give it back to the customer? 1

Smaller numbers cost more. AWS calls the choice a trade-off between RTO and RPO on one side, and cost and complexity on the other. It also warns against a strategy that is stricter than you need. 6

You saw in the replication lesson that a follower copies every change from the leader. That includes a wrong DELETE, so a replica is not a backup. AWS says continuous replication "will not protect you against data corruption or destruction" unless you also have point-in-time recovery. 6

The key idea. A backup counts only after you have restored it and timed the restore, at the size and shape of the disaster you fear. Until then, it is a hope.

Section 3 of 8

How it works

Kinds of backup

A full backup copies everything. It is simple to restore, but big and slow.

An incremental backup holds only what changed since the previous backup. Since version 17, Postgres can take one with pg_basebackup --incremental. To restore it, you need it and every earlier backup it depends on. Postgres does not track that chain for you, so you must not delete a backup that a later one needs. 3

A differential backup holds everything that changed since the last full backup. To restore, you load the full backup, then only the newest differential. Differentials grow every day, so Microsoft suggests a new full backup at set times, for example weekly. 5

There is a second split. A logical backup, like pg_dump, writes rows as SQL. A physical backup copies the database's own files, or a disk snapshot of them. Postgres says logical dumps "do not contain enough information to be used by WAL replay". 3 So they cannot give you point-in-time recovery.

Point-in-time recovery

Point-in-time recovery (PITR) needs two things: a base backup of the data files, and an archive of every write-ahead log (WAL) file since then. To recover, you load the base backup and replay the WAL. You can stop the replay at any moment after the base backup ended. 3

Step through a recovery from a bad DELETE. Use Next and Back, or the ← and → keys.

Point-in-time recovery: restore Sunday's base backup, then replay the log up to just before a bad DELETE Sun 02:00 Tue baseWAL files, archived as they fillevery change since Sunday is kept 14:05 DELETEReplicathe DELETE is copied here too New serverload Sunday's base backup replay WAL to 14:04:59skip Data at risk: writes after 14:05Downtime: 14:05 until the app is back✓ deleted rows are back SeniorPath
  1. A full base backup runs every Sunday at 02:00. After it, the database keeps every write-ahead log (WAL) file in an archive. Together they hold every change since Sunday.
  2. On Tuesday at 14:05, a script runs a DELETE without the right WHERE clause. The replica copies the DELETE a moment later. Replication cannot help you here.
  3. You start a new, empty server and load Sunday's base backup into it. You do not touch the broken primary yet. It may still hold good writes you need.
  4. You tell Postgres to replay the archived WAL and stop at 14:04:59. Every change up to that moment comes back. The DELETE, and everything after it, is skipped.
  5. The rows are back. Good writes made after 14:05 are only on the old primary, so you copy them over by hand. The downtime runs until the app uses the new server. Compare both with your RPO and RTO.
Step 1 of 5

You choose the stop point by time, by a named restore point, or by a transaction ID. 3 You need an unbroken chain of WAL files back to the base backup. One missing file breaks it. Postgres advises you to set up and test WAL archiving before you take your first base backup. 3

A physical PITR restores the whole database cluster, not one table or one customer. 3 Atlassian hit a similar problem at a much larger scale: its data stores were shared by many customers. Restoring one customer from a shared store means a restore to a side server, then a careful copy back.

Where the copies live

The 3-2-1 rule says: keep 3 copies of important data (1 primary and 2 backups), on 2 different media types, with 1 copy offsite. A 2012 US-CERT paper states it and credits it to the second edition (2009) of The DAM Book, a book for photographers by Peter Krogh. 8

In the cloud, "offsite" should also mean "outside your blast radius". AWS says copying backups to another account helps against insider threats or a stolen account. 7

Attackers know where backups are. CISA says "many ransomware variants attempt to find and subsequently delete or encrypt accessible backups". It asks you to keep offline, encrypted backups. 9 An immutable backup cannot be changed or deleted until its retention time ends. CISA notes that some cloud vendors offer this, but says to use it "with caution". It may not meet some compliance rules, and a wrong setting can be costly. 9

Seatbelts against your own mistakes

  • Deletion protection. Amazon RDS will not delete a database while deletion protection is on. It is on by default for databases created in the console. If you delete without keeping automated backups, RDS deletes those backups in the same region. 10
  • A delayed replica. In Postgres, recovery_min_apply_delay = '1h' makes a standby apply each commit only an hour after the primary made it. That gives you time to stop it before a bad change arrives. Longer delays fill its disk with waiting WAL files. 4
  • Soft delete. Mark data as deleted and remove it only later. After the outage, Atlassian committed to soft deletes, keeping deleted data until a retention period ends. 1

Test the restore, and time it

GitLab learned this in 2017. An engineer wiped the primary database while fixing replication, and the replica's data had already been wiped. The team restored from a disk snapshot made six hours earlier, which sat on a staging server. Copying it took around 18 hours, because the disks were throttled to about 60 Mbps. 2 GitLab also wrote that nobody owned the backups, so "nobody was responsible for testing this procedure". 2

AWS says your backup strategy "must include testing your backups", and suggests restoring on a schedule. 7 CISA also asks you to test backups "in a disaster recovery scenario". 9

A good restore test is a job, not a promise. Every week it restores the newest backup to a fresh server. It checks row counts and a few known records. It records how long the restore took, and it pages someone when any step fails.

A game day goes further. The team acts out a whole disaster, with people, runbooks and the clock running. After the outage, Atlassian committed to regular DR exercises that restore every product for a large set of sites at once. 1

Section 4 of 8

Trade-offs

AWS lists four strategies in order of rising cost and complexity, and falling RPO and RTO. The middle two, pilot light and warm standby, keep a second site partly ready. The ranges below are AWS's own. 6

StrategyRPO and RTO (AWS)What runs at the second siteUse it when
Backup and restoreRPO in hours, RTO in 24 hours or less. PITR can bring RPO as low as 5 minutes in some cases.Only backups. You rebuild servers and restore data after the disaster.Most internal tools and young products. It is cheap and simple.
Pilot lightRPO in minutes, RTO in tens of minutes.Data is replicated and always on. App servers are off until you need them.Downtime of an hour hurts, but a second full stack is too costly.
Warm standbyRPO in seconds, RTO in minutes.A smaller but working copy of the whole system. You scale it up.Customer-facing systems where minutes matter.
Multi-site active/activeRPO near zero, RTO potentially zero.Full production in every site, all taking traffic.You already need several regions for users or law.

Simple rule: every strategy still needs point-in-time backups. Even with active/active, a data disaster's recovery point "will always be at some point before the disaster was discovered". 7

Section 5 of 8

At work: how a senior uses this

  • Ask the business for the RPO and RTO of each system, and write them down.
  • Ask, "Which restore have we timed this quarter, and how long did it take?" If nobody knows, the RTO is a guess.
  • List the disasters you plan for: a lost zone, a bad migration, a deleted customer, ransomware. Check that each one has a tested restore of the right shape.
  • Keep at least one backup copy in a separate account, with different credentials, that production scripts cannot delete.
  • Before a risky migration or bulk delete, take a fresh backup and know the restore time. See schema migrations.
  • Alert when a backup job fails or the newest backup is too old.
Section 6 of 8

With AI

What to ask the agent

"Here is our Postgres setup. Write a weekly job that restores the newest base backup and WAL to a fresh server, runs these five checks, records the restore time, and fails loudly if any step fails."

"Read our Terraform. List every database, bucket and backup vault. For each, tell me if deletion protection, versioning or object lock is on, and who can delete it."

What to check yourself

  • The restore test runs against a real, recent backup, not a tiny test database. Restore time grows with data size.
  • The checks look at data, not only at "the server started".
  • The backup credentials are different from the production credentials the agent saw. Code that can reach both is a single point of failure.
  • Retention is long enough to reach back past the time a bug could go unnoticed.
Section 7 of 8

Check yourself

1. Your team has a Postgres primary and two replicas in other zones. Someone runs a DELETE with no WHERE clause. Why do the replicas not save you?

Show answer

The replicas copy the DELETE too, a moment after the primary. Replication copies every change, good or bad. You need a backup that can go back to a moment before the mistake.

2. Your RPO is 15 minutes. You take one full backup every night and nothing else. What is wrong?

Show answer

A crash just before the next backup could lose almost a day of writes, far more than 15 minutes. With only nightly backups, you can lose up to 24 hours of writes. Archiving the WAL for point-in-time recovery closes that gap.

3. Atlassian met its RPO in April 2022 but missed its RTO. What was the main reason?

Show answer

Its restore process was not built for restoring many sites out of shared data stores at once. Atlassian regularly restored one customer or a small set, and could restore all customers into a new environment. It had no tested way to restore hundreds of sites into the live, shared environment.

4. Which DR strategy keeps data copied to a second site, but leaves the app servers there switched off until a disaster?

Show answer

Pilot light In a pilot light setup, the databases and storage are always on, but app servers are created or started only when you fail over.

Your progress is saved only in this browser. Export it to keep it safe.

Was this clear?
Report a mistake (opens GitHub in a new tab)
Section 8 of 8

Go deeper

Show 10 sources and related lessons
  1. Atlassian, “Post-Incident Review on the Atlassian April 2022 outage” (opens in a new tab)
    How 883 deleted sites came back with little data loss, and why it still took up to 14 days.
  2. GitLab, “Postmortem of database outage of January 31” (opens in a new tab)
    Backup methods that were broken or never set up, and an 18-hour copy over slow disks.
  3. PostgreSQL documentation: 25.3. Continuous Archiving and Point-in-Time Recovery (PITR) (opens in a new tab)
    Base backups, WAL archiving, recovery targets and incremental backups, with their limits.
  4. PostgreSQL documentation: 19.6. Replication (opens in a new tab)
    The recovery_min_apply_delay setting for a time-delayed standby, and what it costs.
  5. Microsoft Learn, “Differential Backups (SQL Server)” (opens in a new tab)
    What a differential backup holds, why it grows, and what you need to restore it.
  6. AWS Well-Architected Framework, Reliability Pillar, “REL13-BP02 Use defined recovery strategies to meet the recovery objectives” (opens in a new tab)
    The four DR strategies with their RPO and RTO ranges, in order of cost and complexity.
  7. AWS Whitepaper, Disaster Recovery of Workloads on AWS: Recovery in the Cloud, “Disaster recovery options in the cloud” (opens in a new tab)
    Each strategy in detail, cross-account backups, scheduled restores, and why active/active still needs backups.
  8. Paul Ruggiero and Matthew A. Heckathorn, “Data Backup Options”, US-CERT (Carnegie Mellon University, 2012) (opens in a new tab)
    A short paper that states the 3-2-1 rule and credits it to Peter Krogh's The DAM Book.
  9. CISA, “#StopRansomware Guide” (opens in a new tab)
    Why backups must be offline and tested, and a warning about immutable storage.
  10. Amazon RDS User Guide, “Deleting a DB instance” (opens in a new tab)
    Deletion protection, final snapshots, and what happens to automated backups when you delete a database.

Real incident: Atlassian, 5 Apr 2022: Atlassian outage: a cleanup script deleted 883 sites

Related: Replication · Incident response and postmortems · Schema migrations without downtime · Safe deploys and config changes · Multi-region systems and data locality

Before this: Database replication, to see how followers copy every change. Next: Multi-region systems and data locality, for running in more than one region every day, not only after a disaster.

Related lessons: Incident response and postmortems, Safe deploys and config changes and Requirements and non-functional needs. Case study: the GitLab incident.

Term

See full entry

Jump to a section

  1. 1What broke
  2. 2The idea in simple words
  3. 3How it works
  4. 4Trade-offs
  5. 5At work
  6. 6With AI
  7. 7Check yourself
  8. 8Go deeper