Repository navigation
Bring Postgres and the backup schedule back after a host reboot - #146
Merged
Merged
Conversation
Postgres had no restart policy in either compose file, and Docker's default is "no": after a host reboot the database stayed down while the app, restart: unless-stopped, looped on its boot-time migration. The backup service was restart: "no" so that an unconfigured sidecar, which printed a hint and exited 0, would not restart-loop; that also left a configured schedule stopped after every reboot, so scheduled dumps silently ended. Postgres and backup now use restart: unless-stopped like every other service. Unconfigured, the backup entrypoint prints its hint and then idles (exec sleep infinity) instead of exiting, so the policy has nothing to loop on; the configured path is unchanged. The docs, .env.example and the setup wizard's byte-identical template now say the unconfigured service idles. Co-Authored-By: Claude Opus 5.5 <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 and why
restart:key indocker-compose.ymlordeploy/docker-compose.yml, and Docker's default is"no". After a host reboot the database stayed down while the app (unless-stopped) looped on its boot-time migration. It now usesrestart: unless-stopped.restart: "no". That stopped an unconfigured sidecar (print a hint, exit 0) from restart-looping, but it also meant a configured schedule never came back after a reboot, so scheduled dumps stopped without any warning. Now an unconfiguredscripts/backup/entrypoint.shprints its hint and then idles (exec sleep infinity) instead of exiting, and the service usesrestart: unless-stopped. The configured path behaves exactly as before. Only the comment explaining why a failed start-up dump falls through to the schedule changed.SELF_HOSTING.md,.env.exampleand the setup wizard's byte-identical template now say the unconfigured service idles instead of exiting.Every other service in the compose files (
millionsend,docs,smtp,mx,clamav, andmxindeploy/mx) already hadunless-stopped.docker-compose.prebuilt.ymlonly overrides images.Behavior changes:
BACKUP_CRONstill exits 1. Docker now retries it with backoff, so it shows asRestartingwith the error in the logs instead of stayingExited.depends_onhealth checks. The app retries until Postgres is ready. A backup start-up dump that hits a database that isn't ready yet falls through to the schedule. It is usually skipped anyway, because the bucket already holds a dump from the last 26 hours.Test plan
docker compose configwith all profiles passes fordeploy/docker-compose.yml,docker-compose.yml,docker-compose.yml+docker-compose.prebuilt.ymlanddeploy/mx/docker-compose.yml. Every service resolves torestart: unless-stopped.sh -n,shellcheckand BusyBoxash -nonpostgres:17-alpine(the backup image's base). BusyBox 1.37'ssleepacceptsinfinity.--init, read-only,--cap-drop ALL,no-new-privileges, userpostgres), with--restart unless-stopped. The old entrypoint restart-looped (7 restarts in 8 s). The new one prints the hint once, stays running with 0 restarts, anddocker stopreturns at once.docker compose run --rmstill works on anunless-stoppedservice, so the documented one-off dump and restore commands are unaffected.pnpm lint,pnpm typecheck, and the@millionsend/sestests (including the check thatenvTemplate()is byte-identical to.env.example).🤖 Generated with Claude Code