Add forget option
This commit is contained in:
parent
b83c23b801
commit
ba823b8961
11
backup.nix
11
backup.nix
@ -28,6 +28,11 @@ let
|
|||||||
echo "$output"
|
echo "$output"
|
||||||
fi
|
fi
|
||||||
done
|
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";
|
exit "$exit_code";
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
@ -60,6 +65,11 @@ in
|
|||||||
default = 0;
|
default = 0;
|
||||||
description = "Randomized delay in seconds to spread out backups.";
|
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 {
|
config = lib.mkIf cfg.enable {
|
||||||
systemd.services."backup-helper" = {
|
systemd.services."backup-helper" = {
|
||||||
@ -69,6 +79,7 @@ in
|
|||||||
{
|
{
|
||||||
RESTIC_REPOSITORY = cfg.restic-repository;
|
RESTIC_REPOSITORY = cfg.restic-repository;
|
||||||
BACKUP_HELPER_DIRS = lib.strings.concatStringsSep "," cfg.backup-dirs;
|
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) {
|
// lib.attrsets.optionalAttrs (builtins.hasAttr "password-file" cfg) {
|
||||||
RESTIC_PASSWORD_FILE = cfg.password-file;
|
RESTIC_PASSWORD_FILE = cfg.password-file;
|
||||||
|
Loading…
Reference in New Issue
Block a user