Scaling and changing databases · senior
Backups, point-in-time recovery and DELETE without WHERE
A backup is only real when you have tested a restore. After a wrong DELETE, the goal is to recover the lost rows without losing the new data written since.
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceThe notes
What you must know
- First: stop the script and anything else writing to the table, name one incident owner, and do not make things worse (no restore over production, keep the WAL).
- Business: run in a degraded way (for example, ask for the address again) while the restore runs.
- Options: a point-in-time restore of a copy to just before the mistake (base backup plus WAL, or binlog in MySQL), then copy only that table back; a delayed replica; MySQL binlog flashback tools; last night's backup plus replay.
- Merge: restore into a separate table, insert old rows that do not conflict, keep the new rows, and check foreign keys.
- Restoring last night's backup over production loses the whole day of new data.
- RTO is how long recovery takes. RPO is how much data you can lose. Test restores regularly and measure both. Alert when a backup or WAL archive fails.
- Guardrails: no direct write access to production from laptops, separate credentials per environment, a dry run with a row-count check that aborts, sql_safe_updates in MySQL clients, a delayed replica and reviewed runbooks.
- Communicate with regular updates and write a blameless postmortem.
The red pen
Common traps: mistake → fix
Mistake: We have backups, so we are safe
Fix: only a tested restore counts.
Mistake: Restore the full backup over production
Fix: you lose all new data.
Mistake: Find who did it first
Fix: restore service first; review later without blame.
Easy to hard
Questions interviewers ask, easy to hard
- Someone deleted 12 million rows in production. What do you do first?
- What is point-in-time recovery?
- What are RTO and RPO?
- How do you prevent a script from running on the wrong database?
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceYour first interview is free
Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.