chore(ops): weekly off-Neon pg_dump backup script (#58)#84
Merged
Conversation
Neon's free plan retains only 24h of PITR, so a bad write not caught within a day is unrecoverable. Add scripts/backup-neon.sh: a weekly compressed logical dump to local disk as the disaster-recovery floor. - Reuses the app's connection config: DATABASE_URL (JDBC, jdbc: prefix stripped to a libpq URI) or DB_* fallback. Password is routed to PGPASSWORD (never argv) so it can't leak via ps / /proc/<pid>/cmdline. - Dumps schema-only (--exclude-table-data) for the rebuildable api_response_cache / api_response_body / api_fetch_failure tables to keep dumps small (~9MB vs cache bloat). - Atomic: writes to $OUT.tmp and mv's to the final name only on success, so a failed/partial dump never masquerades as valid or evicts a good backup via the retention prune. - Retention prune keeps the newest CCAS_BACKUP_RETAIN (default 6) dumps. README gains a Backups section (cron line, restore command + pg_restore version note, env knobs); .env.example documents the two backup vars. Smoke-tested against prod Neon: 9.3M dump, valid archive, exclusions verified (excluded tables keep DDL, drop data; 29 core tables retain rows). Closes #58. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds
scripts/backup-neon.sh— a weekly compressed logical dump of the CCAS database to local disk, plus a README Backups section and.env.exampleentries.Why
Neon's free plan retains only 24h of PITR. A bad write not caught within a day is unrecoverable. This is the missing disaster-recovery floor. Pure ops — no Scala touched.
Design
DATABASE_URL(JDBC form,jdbc:prefix stripped to a libpq URI) takes priority, elseDB_*. The password is routed toPGPASSWORD(with urldecode) so it never lands in argv (no leak viaps//proc/<pid>/cmdline).--exclude-table-data) for the rebuildableapi_response_cache/api_response_body/api_fetch_failuretables — restore recreates empty tables, app refills them.$OUT.tmp,mvs to the final name only on success → a failed/partial dump never masquerades as valid or evicts a good backup via the retention prune.CCAS_BACKUP_RETAIN(default 6).Verification
pg_restore --list, 202 entries), exclusions confirmed (3 excluded tables keep DDL, drop data; 29 core tables retain rows).sbt test: 791 passed, 0 failed.Closes #58.
🤖 Generated with Claude Code