fix(release): snapshot SQLite before archiving active WAL databases

This commit is contained in:
cesnimda
2026-11-20 19:26:51 +01:00
parent a30e40bd9c
commit 908295c634
6 changed files with 256 additions and 4 deletions
+5 -4
View File
@@ -289,8 +289,8 @@ backup_database() {
fi
if [ "$provider" = "sqlite" ]; then
# SQLite lives in the jobtracker_data volume. Tar it from a throwaway container
# so the host needs no sqlite tooling and no knowledge of the volume layout.
# Snapshot SQLite through its backup API before archiving the read-only data
# volume. A raw tar can span a WAL checkpoint and omit committed transactions.
#
# docker compose prefixes volume names with the project name, which defaults to
# the directory name. Naming the bare volume here would silently CREATE an empty
@@ -307,11 +307,12 @@ backup_database() {
echo "Backing up SQLite data volume '${volume}' to ${target}"
# The archive path is built inside the container: passing /backup/... as an argument
# gets rewritten by MSYS path translation when the script is run from Git Bash.
if ! docker run --rm \
if ! docker run --rm -i --network none \
-v "$volume":/data:ro \
-v "$BACKUP_DIR":/backup \
-e ARCHIVE_NAME="$(basename "$target")" \
alpine:3 sh -c 'tar czf "/backup/$ARCHIVE_NAME" -C /data .'; then
python:3.12.10-slim-bookworm sh -c 'umask 077; exec python3 - /data "/backup/$ARCHIVE_NAME"' \
< scripts/archive-sqlite-volume.py; then
echo "SQLite volume backup FAILED. Aborting deploy."
rm -f "$target"
return 1