restic handler doesn't initialize test variable
When running the restic handler in test mode, you will see that it fails in a few places because the variable $test
is not defined:
Debug: executing restic backup
Debug: restic backup --repo /mnt/backup '/var/backups' '/var/lib/dpkg/status*' '/var/spool/cron/crontabs' '/etc' '/root' '/home' '/var/www' '/usr/local/*bin' '/var/lib/tor' --exclude /mnt/backup
/usr/share/backupninja/restic: line 343: [: -eq: unary operator expected
Info: Creating new backup snapshot.
Debug: /var/lib/dpkg/status /var/lib/dpkg/status-old does not exist, skipping /var/www does not exist, skipping /usr/local/bin /usr/local/sbin does not exist, skipping /var/lib/tor does not exist, skipping Files: 842 new, 0 changed, 0 unmodified Dirs: 243 new, 0 changed, 0 unmodified Added to the repo: 462.113 MiB processed 842 files, 465.120 MiB in 0:13 snapshot c90dc351 saved
Info: Restic backup successful.
Debug: Unsetting variables
Debug: executing restic prune
Debug: restic prune --repo /mnt/backup
/usr/share/backupninja/restic: line 485: [: -eq: unary operator expected
Info: Removing unreferenced data from repository.
Debug: counting files in repo building new index for repo [0:00] 100.00% 96 / 96 packs repository contains 96 packs (1294 blobs) with 465.238 MiB processed 1294 blobs: 0 duplicate blobs, 0 B duplicate load all snapshots find data that is still in use for 1 snapshots [0:00] 100.00% 1 / 1 snapshots found 1294 of 1294 data blobs still in use, removing 0 blobs will remove 0 invalid files will delete 0 packs and rewrite 0 packs, this frees 0 B counting files in repo [0:00] 100.00% 96 / 96 packs finding old index files saved new indexes as [1d03c884] remove 1 old index files [0:00] 100.00% 1 / 1 files deleted done
Info: Restic prune successful.
Debug: Unsetting variables
Debug: executing restic check
Debug: restic check --repo /mnt/backup
/usr/share/backupninja/restic: line 539: [: -eq: unary operator expected
Info: Checking repository integrity and consistency.
Debug: using temporary cache in /tmp/restic-check-cache-408160703 created new cache in /tmp/restic-check-cache-408160703 create exclusive lock for repository load indexes check all packs check snapshots, trees and blobs no errors were found
Info: Restic check successful.
This is only seen in 'debug' mode, but it isn't good behavior. Adding somewhere at the beginning the following would make this ok:
[ -n "$test" ] || test=0