db-backup
Skill2 starsChanged 35 days agoMITView on GitHub
Back up an app-foundation project's Postgres database every day with GitHub Actions (free), AES-256 encrypted, checked readable, kept 30 days, plus a one-click restore workflow that refuses production by default. Use when the user says "back up my database", "what if I lose my data", "daily backup", "restore my database", "I deleted data by mistake", or another skill requires db-backup.
- Reads credentials
In this repository20 other files it gives its agents.
- AGENTS.mdAGENTS.md
- skills/app-foundation/template/AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- skills/app-foundation/template/CLAUDE.mdCLAUDE.md
- app-foundationSkill
- auth-loginSkill
- db-connectSkill
- deploy-cloudflareSkill
- domain-setupSkill
- email-sendSkill
- env-secretsSkill
- file-uploadSkill
- github-vercel-deploySkill
- launch-kitSkill
- ops-dashboardSkill
- pay-checkoutSkill
- pay-subscriptionSkill
- pay-webhookSkill
- uptime-alertSkill
- warehouse-siteSkill
The file
We split this skill into the rules it gives an agent
2 rules. About 0 are common, 1 is distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 27
Never "test" by deleting production data.
- Very specific: line 60
Before uploading, the encrypted file is decrypted and listed with pg_restore --list.
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
db-backup
Goal: every day GitHub Actions dumps the production database, encrypts it, proves the file can be opened, and keeps it 30 days; one button restores any backup into a database the owner picks. Follow ../../STACK.md.
Why (say this to the owner)
- Neon Free can only rewind 6 hours, keeps 1 manual snapshot and has no scheduled backups (https://neon.com/docs/introduction/plans). A mistake noticed tomorrow is gone.
- GitHub Actions is free: public repos unlimited, private repos 2,000 minutes a month; a backup takes about a minute. Private-repo artifacts share 500 MB of storage (https://docs.github.com/en/billing/concepts/product-billing/github-actions). Re-check both pages before quoting.
- Backups are encrypted, so they're safe even in a public repo (where anyone signed in can download artifacts).
Rules
- The owner adds the secrets in GitHub's settings. Never read, print, copy or type
DATABASE_URL,DB_BACKUP_PASSPHRASEorDB_RESTORE_URL, and never ask for them in chat. - The passphrase is the only key to the backups. Tell the owner to generate it in a password manager and keep it there. Without it, backups can't be opened.
- Restore never goes into production on the agent's initiative. Restore into a new, empty database first; switching the site over (
DATABASE_URLin the host) is the owner's decision. - Never "test" by deleting production data. Practise on the restore database.
Steps
1. Add the workflows
node <skill-dir>/scripts/apply.mjs --dir "<project>" --json # --hour 0-23 (UTC), --keep 1-90 daysAdds db-backup.yml, db-restore.yml, the .env.example note, stack.json → installed, a git save point. Push.
2. Owner: two secrets (a phone works)
https://github.com/<owner>/<repo>/settings/secrets/actions → New repository secret:
DATABASE_URL: Neon → project → Connect → copy the connection string (pooled is fine; the workflow switches to direct).DB_BACKUP_PASSPHRASE: 16+ random characters from a password manager, saved there too.
3. First backup
https://github.com/<owner>/<repo>/actions → Database backup → Run workflow. About a minute later: green ✅; the run summary lists every table with its row count; the artifact db-backup-YYYY-MM-DD holds db.dump.enc and row-counts.txt. From then on it runs daily at 03:17 UTC.
4. Restore drill (do it once)
- Owner: Neon → Databases → New database (e.g.
restore_drill) → Connect, pick that database → copy → GitHub secretDB_RESTORE_URL. - Actions → Database restore → Run workflow, type
RESTORE(run ID empty = latest backup). - Summary: every table with "Rows in backup" = "Rows now". Neon → Tables on
restore_drillshows the data.
Real recovery is the same: restore into a new database, check it, then the owner points DATABASE_URL (host settings, e.g. Cloudflare → Variables) at it, or copies back only the rows they lost.
How it works
pg_dump --format=customwith the client matching the server's major version (Dockerpostgres:<major>-alpine), thenopenssl enc -aes-256-cbc -pbkdf2 -iter 200000.- Before uploading, the encrypted file is decrypted and listed with
pg_restore --list; no table data → the run fails. - Restore:
pg_restore --clean --if-exists --no-owner --no-acl --single-transaction, so it's all or nothing. It refuses whenDB_RESTORE_URLpoints at the same database asDATABASE_URLunless the confirm box saysRESTORE PRODUCTION. - On success the backup inserts
db.backed_upintocore_events(payload: day, bytes, tables, rows).
Troubleshooting
See references/troubleshooting.md.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

