diff --git a/test/compat.sh b/test/compat.sh index e261caa..d57d6ea 100644 --- a/test/compat.sh +++ b/test/compat.sh @@ -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 ===" diff --git a/test/features.sh b/test/features.sh index 7a98232..ca38d6f 100644 --- a/test/features.sh +++ b/test/features.sh @@ -40,6 +40,24 @@ if require_feature stream "PR #109"; then fi stop_container + # Blocker 1 of PR #109: the stream branch must honour RESTIC_JOB_ARGS, the + # same way the file backup does. --host is used because it is visible in + # the snapshot metadata of a stdin backup. + start_container stream-jobargs \ + -e RESTIC_STREAM=1 \ + -e "RESTIC_STREAM_CMD=echo hello-stream" \ + -e RESTIC_STREAM_FILENAME=stream.txt \ + -e "RESTIC_JOB_ARGS=--host=jobargshost" + if wait_for_start; then + in_container /bin/backup >/dev/null 2>&1 + stream_snapshots="$(in_container restic snapshots --json 2>/dev/null)" + assert_contains "$stream_snapshots" '"jobargshost"' \ + "RESTIC_JOB_ARGS is passed to the stream backup" + else + fail "stream RESTIC_JOB_ARGS container starts" + fi + stop_container + # A half-configured stream must not look like a successful backup. start_container stream-misconfigured -e RESTIC_STREAM=1 if wait_for_start; then