Improve backup script
This commit is contained in:
parent
72a5468cb1
commit
ff50a9b4a1
14
backup.nix
14
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
|
||||
|
Loading…
Reference in New Issue
Block a user