Skip to content

fix(backups): make the backup restore drill actually run; unique sessions test port - #197

Merged
afeezorobsco-cyber merged 2 commits into
mainfrom
fix/backup-drill-and-test-port
Oct 20, 2026
Merged

afeezorobsco-cyber merged 2 commits into
mainfrom
fix/backup-drill-and-test-port

Conversation

@afeezorobsco-cyber

Copy link
Copy Markdown
Contributor

Follow-up to #194 and #143, both merged in today's sweep.

Backup restore drill. .github/workflows/backup-restore-drill.yml was invalid YAML, so it has failed on every push to main since #194, without running any job. Both scripts it calls also had shell syntax errors (psal, -symmetric, 3<< <"$KEY", date +%sT', a broken find -printf | cut, mangled ${…\%} expansions), so the drill could never have passed.

  • Workflow: valid BACKUP_ENCRYPTION_KEY expression, correct service options, POSTGRES_USER: drill to match the connection URLs, psql typo fixed, pg_isready -h 127.0.0.1, and permissions: contents: read.
  • scripts/backup-postgres.sh: custom-format pg_dump piped into gpg --symmetric, with the passphrase on fd 3 and loopback pinentry. The plaintext dump never touches disk. Keeps the retention window, and no longer logs the connection string, which contains the password.
  • scripts/restore-drill.sh: same guards (RESTORE_CONFIRM=1, target must end in _drill/_scratch, must not be the source DB), plus a plain-identifier check. It drops and recreates the scratch DB through the postgres maintenance DB, then restores via pg_restore and runs the existing integrity checks.

Test port. tests/integration/sessions.test.mts (#143) used embedded Postgres port 5438, which access-control.test.mts already uses. It's moved to 5451; 5448–5450 have been suggested to open PRs #140, #142 and #144.

ROADMAP.md. The #194 entry described files that don't exist (postgres-backup.yml, restore-drill.mjs, age, docs/backups.md). It now describes what actually shipped, plus a changelog line for this fix.

Verification. Bash syntax-checked locally. The drill was run end to end with workflow_dispatch on this branch (run linked in a comment below).

🤖 Generated with Claude Code

…ions test port

backup-restore-drill.yml (from #194) was invalid YAML, so it failed on
every push to main without running a job. Fix the BACKUP_ENCRYPTION_KEY
expression, the service health-check options and the missing
POSTGRES_USER, and correct the `ps_sql` typo.

Both scripts had shell syntax errors and could never have run. Rewrite
them to the documented behaviour: gpg-encrypted custom-format pg_dump
with retention, and a guarded restore into a *_drill database followed
by integrity checks. gpg reads the passphrase on fd 3 with loopback
pinentry, the scratch DB is recreated through the postgres maintenance
DB, and the backup log no longer prints the connection string.

Move tests/integration/sessions.test.mts from embedded Postgres port
5438 to 5451; 5438 is already used by access-control.test.mts and
integration files run in parallel.

Correct the ROADMAP entry, which described files that don't exist.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Malware scan: passed, with notes for the reviewer

Nothing malicious was detected in 023d5c4. These changes touch sensitive areas and should get a careful look before CI is approved:

Where Rule Why
.github/workflows/backup-restore-drill.yml:8 workflow-change Changes a CI workflow; a maintainer must review before approving runs.
.github/workflows/backup-restore-drill.yml:36 workflow-secret Workflow uses a repository secret.

…allowed in job env

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@afeezorobsco-cyber

Copy link
Copy Markdown
Contributor Author

Drill run on this branch via workflow_dispatch: https://github.com/DocForum/docforum-core/actions/runs/39447143860 ✅. It took an encrypted backup (1252 bytes), restored it into app_drill, and all integrity checks passed (migrations 1, users 1, bookings 1, and the sample booking join returned b-1|confirmed|drill@example.test).

@afeezorobsco-cyber
afeezorobsco-cyber merged commit 50aa986 into main Oct 20, 2026
3 checks passed
@afeezorobsco-cyber
afeezorobsco-cyber deleted the fix/backup-drill-and-test-port branch October 20, 2026 15:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant