Spec a nightly Postgres backup that prunes safely
Your task
Your only Postgres backup today is a manual dump someone takes before big changes. You want a nightly Bash job instead: dump the database, upload it to object storage, delete backups older than 30 days, and alert when something fails. An agent will write the script.
Write the spec you would hand the agent.
What you know:
- Postgres 16, about 40 GB, reachable from a backup host
- dumps go to
s3://acme-db-backups/prod/with the AWS CLI, and other teams keep their own backups under other prefixes in the same bucket - credentials come from the host's IAM role and a
~/.pgpassfile - alerts go to a Slack webhook in
SLACK_WEBHOOK_URL, and cron starts the job at 02:00
Then, in a few sentences: what does a quick "write me a backup script" prompt get wrong?