From 7c995bfdce85f4cbb996268cfc95a581ddedac43 Mon Sep 17 00:00:00 2001 From: Nathan McCarty Date: Sun, 18 Jun 2023 16:33:10 -0400 Subject: [PATCH] Tweak borg to remove long-term server backups --- modules/linux/default.nix | 4 ++++ modules/linux/services/borg.nix | 7 ++++++- 2 files changed, 10 insertions(+), 1 deletion(-) 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 }; }; };