agentleFS
aideploytutoraideploytutor/skill-deploy-share/skills/db-backup/SKILL.md

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

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
  1. Distinctive:

    Never "test" by deleting production data.

    line 27
  2. Very specific:

    Before uploading, the encrypted file is decrypted and listed with pg_restore --list.

    line 60

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

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)

Rules

  • The owner adds the secrets in GitHub's settings. Never read, print, copy or type DATABASE_URL, DB_BACKUP_PASSPHRASE or DB_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_URL in 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 days

Adds 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:

  1. DATABASE_URL: Neon → project → Connect → copy the connection string (pooled is fine; the workflow switches to direct).
  2. 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)

  1. Owner: Neon → Databases → New database (e.g. restore_drill) → Connect, pick that database → copy → GitHub secret DB_RESTORE_URL.
  2. Actions → Database restore → Run workflow, type RESTORE (run ID empty = latest backup).
  3. Summary: every table with "Rows in backup" = "Rows now". Neon → Tables on restore_drill shows 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=custom with the client matching the server's major version (Docker postgres:<major>-alpine), then openssl 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 when DB_RESTORE_URL points at the same database as DATABASE_URL unless the confirm box says RESTORE PRODUCTION.
  • On success the backup inserts db.backed_up into core_events (payload: day, bytes, tables, rows).

Troubleshooting

See references/troubleshooting.md.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.