Interview Prep/SRE & Reliability/Backups, DR & Runbook Automation

The nightly backup job reports success, but the backup files in S3 are 0 bytes.

BeginnerTroubleshootingBackups, DR & Runbook Automation
Answer

Likely causes → The script pipes pg_dump | gzip | aws s3 cp -, and without pipefail only the last command's exit code counts; pg_dump failed (auth, connection) but the upload succeeded with empty input.

Diagnose → Check job logs for pg_dump errors and list object sizes:

aws s3 ls s3://backups/orders/ --human-readable | tail

Fix →

set -euo pipefail
pg_dump -Fc "$DATABASE_URL" | aws s3 cp - "s3://backups/orders/$(date +%F).dump"

Prevent → Alert on backup size anomalies and age, and verify each backup with a restore or at least pg_restore --list.

All SRE & Reliability questions Roadmap: Backup & disaster recovery

More on Backups, DR & Runbook Automation