Fix SIGTERM forwarding, harden image, restructure repo, add e2e CI tests - #227
Conversation
️✅ There are no secrets present in this pull request anymore.If these secrets were true positive and are still valid, we highly recommend you to revoke them. 🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request. |
|
These were dummy CI test passphrases with no real credentials behind them. Extracted all three to job-level |
Signal handling - Add borgmatic-start wrapper (/usr/local/bin/borgmatic-start) that traps TERM/INT/HUP, forwards the signal to borgmatic by PID, and waits for clean exit. Prevents docker stop from killing borgmatic mid-backup and leaving a stale repository lock. Closes #104. - Add stop_grace_period: 10m to docker-compose.yml. - Warn at startup if the active crontab calls borgmatic directly instead of borgmatic-start. Script hardening - Replace eval+set|grep secret expansion with safe compgen -e and bash indirect expansion (${!var}). - Fix EXTRA_CRON missing leading newline before append. - Fix post-loop debug labels printing "Before" instead of "After". - Split EXTRA_PKGS via read -ra instead of fragile unquoted word splitting. Upstream sync (borgmatic-collective/docker-borgmatic) - Add init-envfile S6 oneshot: processes FILE__VARNAME env vars, writes secret file contents to container environment (LinuxServer.io convention). - Alpine 3.23 → 3.24. - S6_CMD_WAIT_FOR_SERVICES_MAXTIME reverted to 0 (upstream default). Repo restructure - Move all files from base-fullbuild/ to repo root, preserving git history. - Remove sync-drone-tags.yml workflow (Drone now generates tags dynamically from requirements.txt via a Prepare step). - Remove Drone lint step (Hadolint + ShellCheck run in GitHub Actions CI). Renovate - Extract ALPINE_VERSION and PYTHON_VERSION as ARGs in Dockerfile so Renovate can track each independently via regexManagers. Config examples and documentation - Update all example configs from borgmatic 1.x to 2.x flat format. - Update hook examples from deprecated before_everything/after_everything/ on_error to commands: syntax. - Fix docker-compose.restore.yml: paths, BORG_PASSPHRASE, shell. - Rename VOLUME_RESTORE to BORG_RESTORE in restore compose and .env.template. - Add VOLUME_BORGMATIC_STATE to .env.template. - README: Configuration section (example files, env var expansion, Healthchecks.io), Hook scripts, signal handling, secret files, FUSE restore walkthrough, log rotation. - Add .gitignore excluding .claude. Example borgscripts (data/borgscripts/) - docker-stop.sh: stop containers carrying a configurable label before backup. Uses --no-run-if-empty to guard against empty matches. - docker-start.sh: start a single compose stack with docker compose start (not up -d) to avoid unintended recreates. - redis-backup.sh: trigger BGSAVE and poll rdb_bgsave_in_progress until the snapshot is complete before borgmatic runs. - README documents all three scripts with setup, label config, borgmatic hook wiring, and Docker requirements. New native database backup section covers borgmatic's built-in PostgreSQL, MariaDB, MongoDB, SQLite support. CI — end-to-end and behavioural tests - Full backup cycle: repo-create, create, list (assert archive count), borg list (assert expected filenames present in archive). - ${VAR} expansion in borgmatic config: source_directories and encryption_passphrase read from container env vars. - encryption_passcommand: passphrase read from a mounted secrets file. - Invalid config rejection: borgmatic config validate exits non-zero for keep_daily: "not-a-number". - SIGTERM forwarding: mock borgmatic traps TERM, borgmatic-start forwards signal, assert "Caught signal" or BORGMATIC_SIGTERM_RECEIVED in logs. - FILE__VARNAME expansion: container started with FILE__MY_SECRET, assert MY_SECRET set in /run/s6/container_environment/ and FILE__ var removed. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
69c07af to
5b49a5f
Compare
Summary
Signal handling
Script hardening
Upstream sync (borgmatic-collective/docker-borgmatic)
Repo restructure
Renovate
Config examples & documentation
Example borgscripts
Three ready-to-use hook scripts in `data/borgscripts/` (all require `DOCKERCLI=true` + `docker.sock`):
CI — end-to-end tests
Four new tests that run borgmatic against a real Borg repository (no S6):
What reviewers should know
Test plan