Merge pull request 'Add forget option' (#2) from 1-forget-option into master

Reviewed-on: #2
This commit is contained in:
Torjus Håkestad 2024-10-03 23:20:05 +00:00
commit e84295ad59

View File

@ -28,6 +28,11 @@ let
echo "$output"
fi
done
if [ "$BACKUP_FORGET" -eq 1 ]; then
echo "Removing old backups"
output=$(restic forget -d 7 -w 4 -m 6 --keep-within 1d --prune)
echo "$output"
fi
exit "$exit_code";
'';
};
@ -60,6 +65,11 @@ in
default = 0;
description = "Randomized delay in seconds to spread out backups.";
};
forget = lib.mkOption {
type = lib.types.bool;
default = true;
description = "Run restic forget after backup.";
};
};
config = lib.mkIf cfg.enable {
systemd.services."backup-helper" = {
@ -69,6 +79,7 @@ in
{
RESTIC_REPOSITORY = cfg.restic-repository;
BACKUP_HELPER_DIRS = lib.strings.concatStringsSep "," cfg.backup-dirs;
BACKUP_FORGET = if cfg.forget then "1" else "0";
}
// lib.attrsets.optionalAttrs (builtins.hasAttr "password-file" cfg) {
RESTIC_PASSWORD_FILE = cfg.password-file;