Warn when borgmatic is run directly instead of via borgmatic-start#240
Merged
Conversation
borgmatic-start traps SIGTERM/INT/HUP and forwards signals to the borgmatic process. Running borgmatic directly (e.g. docker exec) bypasses this, meaning a container stop during a backup won't be handled gracefully. Implementation: - Rename the pip-installed borgmatic binary to borgmatic.bin - Add a wrapper at borgmatic that checks for BORGMATIC_VIA_START env var and prints a warning if absent, then exec's borgmatic.bin - Set BORGMATIC_VIA_START=1 in borgmatic-start to suppress the warning Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
DL3013: pip install -U pip is intentionally unpinned (always want latest pip) DL3018: borgmatic-bash-completion unpinned (tracks borgmatic version from Alpine) DL3042: --no-cache-dir omitted intentionally — using BuildKit cache mount instead Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
with-contenv reads /run/s6/container_environment which doesn't exist when borgmatic is run directly (--entrypoint or docker exec before s6 init). The wrapper is a thin passthrough and doesn't need the s6 container environment. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The borgmatic wrapper now prints a WARNING containing 'borgmatic' before s6 init completes. The CI test was polling for 'borgmatic' in logs as a readiness signal, which fired immediately on the warning — before svc-cron/run had printed the version table. 'Time Zone:' only appears at the end of the version table, making it a reliable sentinel that the container is fully initialised. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…check borgmatic --version at startup hits the wrapper which emits the BORGMATIC_VIA_START warning, since s6 init is not a backup run. Use borgmatic.bin directly for the version display — the wrapper warning is only meaningful for actual backup invocations. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
3 tasks
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.
Summary
borgmatic-starttrapsSIGTERM/INT/HUPand forwards them to the borgmatic process, so adocker stopduring a backup is handled gracefully. Running borgmatic directly viadocker execbypasses this entirely with no indication to the user.This PR adds a runtime warning when borgmatic is invoked outside of
borgmatic-start:The warning is suppressed automatically when called via
borgmatic-start(which setsBORGMATIC_VIA_START=1).Implementation:
borgmatic→borgmatic.binafter installroot/usr/local/bin/borgmatic: wrapper that checksBORGMATIC_VIA_STARTand warns if unset, thenexecsborgmatic.binroot/usr/local/bin/borgmatic-start: prefix the borgmatic call withBORGMATIC_VIA_START=1Test plan
docker exec Borgmatic borgmatic --versionprints the warningdocker exec Borgmatic borgmatic-start --versiondoes not print the warningborgmatic-start) do not print the warning