Bugpit

Lessons › Design skills

Undo a mistake

At 2 p.m. an engineer runs a delete without its filter, and every order is gone. Your database has a standby and a read replica. Within a second, both of them have faithfully deleted every order too.

Play this level

Part of Bugpit Pro. It runs in your browser: build the design, press Run, and watch what breaks.

The lesson

Replicas and standbys protect you from a machine dying. They don't protect you from a mistake, because they copy every change, including the wrong ones.

A backup is a copy from an earlier time, kept apart. With point in time recovery the database also keeps its log of changes, so you can rebuild it as it was at 1:59 p.m. Click **Primary DB** and tick **Backups**.

Two numbers describe a recovery plan. RPO, the recovery point objective, is how much recent data you can afford to lose. With nightly backups that's up to a day. With point in time recovery it's minutes. RTO, the recovery time objective, is how long you can be down while you restore.

A backup you've never restored is a hope, not a plan. Restore one on a schedule and time it. Keep a copy somewhere else too, in another region or account, so whatever destroys the database can't reach the backup.

This simulator can't lose data, so it only checks that backups are on. The questions cover the rest.

What you have to achieve

3,000 requests a second at the busiest hour, 5% of them writes.

What you learn

The orders can be brought back as they were at 1:59 p.m. Restoring a large database can take hours, and that time is your RTO. Decide what the business can live with before the bad day, not during it.

Check yourself

Why didn't the replica save the orders?

Show the answer

It copies every change, including the delete. A replica's job is to match the primary. It can't tell a mistake from a real change.

You take one backup a night, at midnight. The database is destroyed at 6 p.m. How much data can you lose?

Show the answer

Up to 18 hours. Everything since the last backup is gone. That gap is your RPO.

What does RTO measure?

Show the answer

How long you can be down while you recover. RTO is about time to recover. RPO is about data lost. A plan needs both.

How do you know your backups work?

Show the answer

You restore one regularly and check the data. Only a restore proves it. Teams have found on the worst day that their backups were empty or unreadable.

Try it yourself

More in Design skills

← Count the nines Three copies, no leader →