diff --git a/modules/linux/default.nix b/modules/linux/default.nix index de4aa34..c651be8 100644 --- a/modules/linux/default.nix +++ b/modules/linux/default.nix @@ -81,6 +81,10 @@ in { description = "How often to run backups"; default = "hourly"; }; + keepForever = mkOption { + description = "Keep monthly backups forever"; + default = config.nathan.config.isDesktop; + }; }; # Nginx nginx = { diff --git a/modules/linux/services/borg.nix b/modules/linux/services/borg.nix index 9aa32e9..31da8a3 100644 --- a/modules/linux/services/borg.nix +++ b/modules/linux/services/borg.nix @@ -28,11 +28,16 @@ with lib; { environment.BORG_RSH = "ssh -i ${config.nathan.services.borg.sshKey}"; compression = "auto,zstd"; startAt = config.nathan.services.borg.startAt; - prune.keep = { + prune.keep = if config.nathan.services.borg.keepForever then { within = "7d"; # Keep all archives for the past week daily = 1; # Keep 1 snapshot a day for 2 weeks weekly = 4; # Keep 1 snapshot a week for 4 weeks monthly = -1; # Keep unlimited monthly backups + } else { + within = "7d"; # Keep all archives for the past week + daily = 1; # Keep 1 snapshot a day for 2 weeks + weekly = 4; # Keep 1 snapshot a week for 4 weeks + monthly = 3; # Keep 3 monthly backups }; }; };