Backups have "succeeded" every night for a year, but the first real restore failed. How do you make backups trustworthy?
AdvancedScenarioScenarios: backups, log rotation and housekeeping
Answer
Situation read → Nobody tested restores, so "success" only meant "the script exited 0".
What I'd do →
- Add an automated restore test on a schedule (weekly), in an isolated environment:
latest=$(aws s3 ls "s3://$BUCKET/pg/" | sort | tail -n1 | awk '{print $4}') aws s3 cp "s3://$BUCKET/pg/$latest" /restore/ createdb restore_test && gunzip -c "/restore/$latest" | psql -v ON_ERROR_STOP=1 -q restore_test psql -tAc 'select count(*) from orders' restore_test # compare with production metrics - Assert on content: row counts within a tolerance, the latest record's timestamp is recent, critical tables exist.
- Verify checksums of archives before restoring, and alert if the newest backup is older than 26 hours.
- Record restore duration as a metric; that is your real RTO.
- Document the restore runbook and rehearse it.
Why → A backup you have not restored is a hypothesis, not a backup.
Interview tip → Use "RTO and RPO" and say restore tests produce the evidence for both.
More on Scenarios: backups, log rotation and housekeeping
Design a nightly backup of `/etc` and application data to S3 with retention.IntermediateWrite the core of a Postgres backup that streams `pg_dump` through gzip to S3 and never uploads an empty dump.Intermediate`/var` is 100% full because an app's logs were never rotated, and the app now fails to start. What do you do now, and what do you set up after?BeginnerShould you use `copytruncate` or a `postrotate` signal for an application's logs? How do you decide?Intermediate`/srv/app/releases` has 300 old release directories. Write a cleanup that keeps the newest 5 and never deletes the current release.BeginnerA Docker host keeps filling its disk. Write a safe cleanup approach.Beginner