From de3f8f8909a4a7af81f6125da440840788a26087 Mon Sep 17 00:00:00 2001 From: Simon Bruder Date: Fri, 28 May 2021 14:54:45 +0200 Subject: [PATCH] restic: Make restic prune regularily on fuuko Closes #41. --- machines/fuuko/configuration.nix | 1 + modules/restic/system.nix | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/machines/fuuko/configuration.nix b/machines/fuuko/configuration.nix index 695c532..7b90137 100644 --- a/machines/fuuko/configuration.nix +++ b/machines/fuuko/configuration.nix @@ -35,6 +35,7 @@ "/data/misc" "/data/torrent" ]; + prune = true; }; unfree.allowSoftware = true; }; diff --git a/modules/restic/system.nix b/modules/restic/system.nix index a1f55ee..02c556b 100644 --- a/modules/restic/system.nix +++ b/modules/restic/system.nix @@ -64,6 +64,7 @@ in type = lib.types.nullOr lib.types.int; default = 1500; }; + prune = lib.mkEnableOption "pruning"; }; config = lib.mkIf cfg.enable { @@ -98,6 +99,25 @@ in "IOSchedulingPriority" = 7; }; + services.restic.backups.system-prune = lib.mkIf cfg.prune { + inherit repository; + passwordFile = config.sops.secrets.restic-password.path; + s3CredentialsFile = config.sops.secrets.restic-s3.path; + timerConfig = { + OnCalendar = "*-1/2-07 03:00:00"; + RandomizedDelaySec = "4h"; + }; + paths = [ ]; + pruneOpts = [ + "--keep-daily 7" + "--keep-monthly 12" + "--keep-weekly 5" + "--keep-yearly 10" + "--tag system" + "--verbose" + ] ++ lib.optional (cfg.uploadLimit != null) "--limit-upload=${toString cfg.uploadLimit}"; + }; + environment.systemPackages = [ authScript ];