Restore Drill
You'll back up a database you care about every night without touching it, then on a day you choose, break the database on purpose and get it back from the backup alone.
About
Until you've restored from a backup, you don't know whether you have one. Most people find out on the worst day of their year, and this badge is about finding out on a Tuesday you picked. Take one database you actually use (the one from Schema From Scratch, your Postgres practice database, or a copy of a hidden table), back it up every night by schedule, check the backups are good, and then delete a table on purpose and bring it back. The second half adds a copy somewhere other than the same disk, because a dead drive takes the backups with it. The gear is free: cron or Task Scheduler, pg_dump or sqlite3's .backup, and any second place from a USB stick to free cloud storage. What counts is thirty nightly backups, a timed restore, and a restore from the off-site copy on a different machine.
At a glance
- Per requirement
- 35 XP
- Completion bonus
- 300 XP
- Requirements
- 6
- Takes
- A month
- Skill level
- Intermediate (months of practice)
- Cost
- Free
- Supplies
- Nothing special
- Where
- At home
- Other people
- On your own
Requirements
-
1
Write a one-line backup command, run it by hand, and check that the file opens. For SQLite, sqlite3 live.db '.backup backups/live-2025-03-01.db', which is safe while the database is in use where a plain copy isn't. For Postgres, pg_dump -Fc practice > backups/practice-2025-03-01.dump. Then open the result: sqlite3 on the copy with a COUNT(*), or pg_restore --list on the dump. A file that exists but won't open is the most common fake backup. Take a screenshot of the command and the check. Photo
-
2
Schedule it nightly with a dated filename and show seven files a week later. A cron line like 0 2 * * * /home/you/backup.sh, or a Task Scheduler entry on Windows, with the date in the filename from date +%F. Keep the script next to the backups so the two never drift apart. Take a screenshot of the folder listing with seven dated files and their sizes. Photo
-
3
Add a check that complains loudly when a backup is empty or missing, and trip it on purpose. The script compares the new file's size to yesterday's and refuses to stay quiet if it's zero or under half, with an email, a chat message, or a line in a log you actually read. Point it at a wrong path once to make it fail, and show the complaint arriving. Take a screenshot of the check and the alert. Photo
-
4
Drop a table on purpose and restore it from last night's backup, timing the whole thing. Note the time, run DROP TABLE, then restore. In SQLite, ATTACH the backup file and CREATE TABLE ... AS SELECT from it, which brings back the one table without undoing today's changes elsewhere; in Postgres, pg_restore -d practice -t tablename pulls one table out of the dump. Check that the row count matches last night's. Write down the minutes it took, which is your recovery time and the number people will ask about. Film it. Video
-
5
Copy the backups somewhere that isn't this disk, and restore the newest one on a different machine. rsync or rclone to a USB stick, a second computer, or free cloud storage, scheduled to run after the backup. Then, on another machine (a friend's laptop, a Pi, a free cloud VM), pull the newest file down and open it with a row count that matches. If the database has anything private in it, encrypt the copy first with age or gpg, and keep the key somewhere other than beside the backup. Take a screenshot of the other machine with the restored database open. Photo
-
6
After thirty nights, write a half-page restore runbook that someone else could follow. Where the backups are, how to restore one table and the whole database, what to check afterwards, and how long it takes. Post the page with the thirty-file listing. Photo