diff --git a/backup.nix b/backup.nix index d21cafd..d2df465 100644 --- a/backup.nix +++ b/backup.nix @@ -5,16 +5,26 @@ let name = "restic-wrapper"; runtimeInputs = [ pkgs.restic - pkgs.systemd ]; text = '' if [ -z "$BACKUP_HELPER_DIRS" ]; then - echo "BACKUP_HELPER_DIRS is not set"; + echo "BACKUP_HELPER_DIRS is not set" exit 1; fi + exit_code=0; for i in ''${BACKUP_HELPER_DIRS//,/ }; do echo "Starting backup of $i"; + output=$(restic backup "$i" && rc=$? || rc=$?); + if [ $rc -ne 0 ]; then + echo "Backup of $i failed with exit code $rc:" + echo "$output" + exit_code="$rc" + else + echo "Backup of $i successful:" + echo "$output" + fi done + exit "$exit_code"; ''; }; in