mirror of
https://github.com/lobaro/restic-backup-docker.git
synced 2026-11-14 16:02:43 +00:00
test: prove RESTIC_JOB_ARGS reaches restic backup
The suite recorded RESTIC_JOB_ARGS only indirectly through backup-last.log,
which proves nothing about restic ever seeing the arguments. Removing
${RESTIC_JOB_ARGS} from the restic backup call in backup.sh left compat at
32 passed, 0 failed - exactly the failure class this PR is supposed to
catch, and exactly blocker 1 of PR #109.
compat.sh gets a section that runs a backup with
RESTIC_JOB_ARGS=--exclude=/data/skipme.txt and requires the excluded file
to be absent from the restore while the other file is restored intact, so
the arguments must have a visible effect.
features.sh gets the matching assertion inside the existing `stream`
feature gate (RESTIC_JOB_ARGS=--host=jobargshost must show up in the
snapshot metadata of a stdin backup). It is reported as SKIP until PR #109
is rebased, which is the point of the gate.
Verification on Git-Bash:
bash test/run.sh -> structure 13/13, compat 39 passed 0 failed,
features 4 SKIP, exit 0
sabotage (backup.sh:40 ${RESTIC_JOB_ARGS} removed), rebuilt image
IMAGE=rbd-sab-jobargs bash test/compat.sh
-> FAIL RESTIC_JOB_ARGS is passed to restic backup
"the excluded file was backed up anyway"
-> 38 passed, 1 failed, exit 1
backup.sh was restored with git checkout and the sabotage image removed.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Agent-Id: agent-4966d0e6-7f4d-4b37-be3d-0648ed56cb8a
This commit is contained in:
1 parent
0aced54891
commit
c138bd24d3
2 files changed
+42
No files matched your search
@@ -133,6 +133,30 @@ assert_eq "1" "$(snapshot_count)" \
|
||||
"--keep-last 1 leaves exactly one snapshot"
|
||||
stop_container
|
||||
|
||||
echo
|
||||
echo "=== compat: RESTIC_JOB_ARGS ==="
|
||||
# backup-last.log only records the variable, it does not prove restic ever saw
|
||||
# it. The arguments have to have a visible effect, otherwise a backup that
|
||||
# silently drops RESTIC_JOB_ARGS still looks healthy.
|
||||
|
||||
start_container jobargs -e "RESTIC_JOB_ARGS=--exclude=/data/skipme.txt"
|
||||
wait_for_start || { fail "container starts with RESTIC_JOB_ARGS"; summary "compat"; exit 1; }
|
||||
write_file /data/keep.txt "keep"
|
||||
write_file /data/skipme.txt "skip"
|
||||
jobargs_log="$(in_container /bin/backup 2>&1)"
|
||||
assert_contains "$jobargs_log" "Backup Successful" \
|
||||
"backup with RESTIC_JOB_ARGS succeeds"
|
||||
in_container restic restore latest --target /tmp/restore >/dev/null 2>&1
|
||||
assert_eq "keep" "$(in_container cat /tmp/restore/data/keep.txt 2>&1)" \
|
||||
"RESTIC_JOB_ARGS does not break a normal backup"
|
||||
if in_container test -f /tmp/restore/data/skipme.txt; then
|
||||
fail "RESTIC_JOB_ARGS is passed to restic backup" \
|
||||
"the excluded file was backed up anyway"
|
||||
else
|
||||
pass "RESTIC_JOB_ARGS is passed to restic backup"
|
||||
fi
|
||||
stop_container
|
||||
|
||||
echo
|
||||
echo "=== compat: BACKUP_SOURCES ==="
|
||||
|
||||
|
||||
Reference in new issue
Block a user