Repository navigation
Conversation
Makes deploy/compose.yaml usable unchanged, with only a .env, on a server that pins every image and deploys with nothing but `docker compose up -d`. - POSTGRES_VERSION (default 17-alpine) is the tag of db and the backup services, so an exact release can be pinned without editing the file. - backup-scheduled: the backup definition on a daily loop (YAML anchor), restart unless-stopped, turned on with COMPOSE_PROFILES. It waits for the database after a reboot. `backup` only takes single dumps now. - BACKUP_DIR (default ./backups) puts the dumps on another disk. - pg-major-upgrade.sh stops the scheduled backup for the upgrade and moves it to the new image. - Self-hosting guide: pinning every version, Nginx Proxy Manager, a monitor on /api/health, restoring without root on the host, moving an instance or a development database to another machine. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
- A restart takes no extra dump: at start the scheduled service waits until the newest dump is as old as the interval. - A database with no accounts is never dumped or pruned, so an empty database cannot push the real backups out. - A failed dump is tried again after 10 minutes (6 in a row, then the interval); bad settings fall back with a warning instead of putting the container in a restart loop. - A stop during a dump ends pg_dump and removes its unfinished file. - pg-major-upgrade.sh installs its recovery before stopping anything. - Guide: restores stop the scheduled backup, BACKUP_DIR must be a path, an unmounted disk, and what a Postgres tag does and does not pin. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…view fixes - pg-major-upgrade.sh: the recovery is an EXIT trap behind an `armed` flag. The ERR trap never ran for a failure inside a function (dc, psql_db, up_all) or a subshell, so a new server that did not start or a failed restore left the app stopped and the override pointing at the new, empty volume. - Backups: pruning never decides the result (a file that cannot be removed is a warning); a failed rename removes the unfinished file; the unfinished file is named per container, so two runs in the same second never write the same file. - Guide: a dump made by hand for a move gets a name the backups do not prune; from a clone, BACKUP_DIR stays at ./backups or outside it. Co-Authored-By: Claude Fable 5.2 <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.
Why
The app already ran in Docker. What it could not do was fit a server that follows three rules: every image pinned to an exact version, a stack deployed with nothing but
docker compose up -d, and an operator without root on the Docker host. This makesdeploy/compose.yamlusable there unchanged, configured only from a.env:What changes
postgres:17-alpinewas hard-coded, a floating tagPOSTGRES_VERSION(default17-alpine) sets the tag ofdband the backup services--profile backup up -d backup) and ended at every rebootbackup-scheduledservice: the same definition asbackup(YAML anchor),restart: unless-stopped, on withCOMPOSE_PROFILES=backup-scheduled. It dumps at start and everyBACKUP_INTERVAL_HOURS(default 24), and waits for the database after a rebootBACKUP_DIR(default./backups)sudodocker compose run --rm --entrypoint pg_restore backup …)pg-major-upgrade.shknew onlydbandbackupDocs (
docs/SELF-HOSTING.md): pinning every version, Nginx Proxy Manager (works with its defaults), a monitor on/api/health, restoring without root, and moving an instance or a development database to another machine.SPEC.md,DECISIONS.md,CHANGELOG.mdandCLAUDE.mdfollow.Behaviour change
backupnow only takes single dumps.BACKUP_INTERVAL_HOURSwithdocker compose --profile backup up -d backupused to loop; it now dumps once and exits. The schedule isCOMPOSE_PROFILES=backup-scheduled. In return,docker compose run --rm backupis always one dump, whatever.envsays. The changelog has the upgrade note.Not added, on purpose:
container_name(breaks a second instance with-p), a variable for a bind-mounted data folder, and health check tuning (Docker 28 keeps probe results in memory, so the 5-secondpg_isreadywrites nothing to disk).How it was checked
No app code changes, so the published
sha-164fb53image was run with this branch'sdeploy/compose.yamland a.envlike the one above, under a throwaway project name (Docker 29.10, Compose 5.8, macOS):up -dstarts the three services on the pinned images; the scheduled dump, one-shotrun --rm backupnext to it, and pruningpg-major-upgrade.sh17 → 18 with the schedule running0.1.0dump restored the same way (migration0007applied), and over a database the newer app had already run on (fails, as the guide now warns)proxy_request_buffering off, over TLS and HTTP/2, in Chromium: register,Securesession cookie, a 4.6 MB / 40,000-row import, sign out and innpm run typecheck,npm run lint,npm test(1174 tests)Not checked: Nginx Proxy Manager itself, a real reboot or Docker daemon restart, an unprivileged LXC, Docker 28, and the move with real data.
docs/DECISIONS.md("Not verified") has the full list.After merging
The deployment needs a release to pin (
make release VERSION=0.2.0 PUSH=1); the steps that follow are under "Next steps" indocs/DECISIONS.md.🤖 Generated with Claude Code