Backups and Recovery: Testing the Restore Before Disasters
Understand the idea
Why an untested backup is merely an unverified hope when disaster strikes.
The idea
The most important rule in database operations is: 'An untested backup is not a backup; it is only a wish.' A database provides under normal operations, but when disasters happen, teams often discover that their backup files were incomplete, damaged, or cannot be restored.
A reliable database recovery setup needs two things:
- Automated Test Restores: A backup is only proven when an automated job regularly restores the backup file into a temporary sandbox database, checks row counts, and verifies that the data is healthy.
- Continuous Archiving & : Standard daily backups mean you can only restore back to last night, losing up to 24 hours of user data. Modern databases (like PostgreSQL) combine periodic base backups with continuous archiving. With PITR, you can roll back your database to any exact second (for example, 11:42:15 AM-one second before an accidental command deleted important data).
What changes
| Backup Strategy | Recovery Point Objective (RPO) | Recovery Time Objective (RTO) | Best Used For |
|---|---|---|---|
| Daily Logical Dump (pg_dump / mysqldump) | Up to 24 hours of lost data | Slow: must re-execute all SQL inserts | Small databases, offline archives, test environments |
| Physical Snapshot (EBS / Disk Snapshot) | Hours of lost data | Fast: mounts pre-formatted disk block image | Disaster recovery of large multi-terabyte clusters |
| Point-In-Time Recovery (Base + WAL) | Seconds to minutes (near-zero data loss) | Moderate: replays WAL log delta to target second | Mission-critical production systems, compliance |
The command
Automated backup restore verification script
3s timeout · one stateless run. Node and Express use Piston when that instance accepts the job (public EMKC execute is whitelist-only; set PISTON_URL or PISTON_TOKEN). Otherwise a local Node process. MongoDB uses a fresh in-memory server per run, then it is stopped.
The mistake
Check the result
Run the example to see an automated pipeline export database state, restore it into a clean disposable sandbox, and verify row checksums.
Guided challenge
Verify backup reliability criteria
Update the function so it returns true only when hasTestedRestore is true AND dumpFileSizeBytes > 0.
Verify backup reliability criteria
3s timeout · one stateless run. Node and Express use Piston when that instance accepts the job (public EMKC execute is whitelist-only; set PISTON_URL or PISTON_TOKEN). Otherwise a local Node process. MongoDB uses a fresh in-memory server per run, then it is stopped.
EXPECTED RESULT
true false
Hints 0/1
Use all hints or make 3 failed checks (0/3).
Free exploration
Change this example and run it again. Each run is a new process. Nothing is saved.
Your variation
3s timeout · one stateless run. Node and Express use Piston when that instance accepts the job (public EMKC execute is whitelist-only; set PISTON_URL or PISTON_TOKEN). Otherwise a local Node process. MongoDB uses a fresh in-memory server per run, then it is stopped.
Quiz
A quick check for understanding. Retry as often as you like; your learning path stays open.
Ready to call this one understood?
Mark this lesson complete to earn 200 XP. You can always revisit it.