summary refs log tree commit diff
path: root/nixos/modules/services/backup
diff options
context:
space:
mode:
authorThiago Kenji Okada <thiagokokada@gmail.com>2022-10-12 21:26:00 +0100
committerGitHub <noreply@github.com>2022-10-12 21:26:00 +0100
commitb87716afc94cc987e95cc36e081a2fc35f1f0f7c (patch)
tree5e3f8df3f59d498e364ab618e77626d737155032 /nixos/modules/services/backup
parentd0ac2bea9c3bb9bac58e56123b96c9a0ed2ef002 (diff)
parentdd34f474ed6c719c094085e24108888761ab2b67 (diff)
Merge pull request #188881 from shadaj/patch-4
nixos/restic: make it possible to use the existing backup cache for prune/check
Diffstat (limited to 'nixos/modules/services/backup')
-rw-r--r--nixos/modules/services/backup/restic.nix16
1 files changed, 14 insertions, 2 deletions
diff --git a/nixos/modules/services/backup/restic.nix b/nixos/modules/services/backup/restic.nix
index 65fe34b2d39e4..869ed5d9976c3 100644
--- a/nixos/modules/services/backup/restic.nix
+++ b/nixos/modules/services/backup/restic.nix
@@ -196,6 +196,18 @@ in
           ];
         };
 
+        checkOpts = mkOption {
+          type = types.listOf types.str;
+          default = [ ];
+          description = lib.mdDoc ''
+            A list of options for 'restic check', which is run after
+            pruning.
+          '';
+          example = [
+            "--with-cache"
+          ];
+        };
+
         dynamicFilesFrom = mkOption {
           type = with types; nullOr str;
           default = null;
@@ -270,8 +282,8 @@ in
               then if (backup.paths != null) then concatStringsSep " " backup.paths else ""
               else "--files-from ${filesFromTmpFile}";
             pruneCmd = optionals (builtins.length backup.pruneOpts > 0) [
-              (resticCmd + " forget --prune " + (concatStringsSep " " backup.pruneOpts))
-              (resticCmd + " check")
+              (resticCmd + " forget --prune --cache-dir=%C/restic-backups-${name} " + (concatStringsSep " " backup.pruneOpts))
+              (resticCmd + " check --cache-dir=%C/restic-backups-${name} " + (concatStringsSep " " backup.checkOpts))
             ];
             # Helper functions for rclone remotes
             rcloneRemoteName = builtins.elemAt (splitString ":" backup.repository) 1;