summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregor Kleen <gkleen@yggdrasil.li>2018-04-23 16:06:25 +0200
committerGregor Kleen <gkleen@yggdrasil.li>2018-04-23 16:06:25 +0200
commitf129fe34bf7fb114740f8d088e400bd74a97409f (patch)
treebcd57cd12eb038f6dcb1055c8ed0966018d000e7
parent8351d19546129107baecaab044e8bc14f6221f3f (diff)
downloadnixos-f129fe34bf7fb114740f8d088e400bd74a97409f.tar
nixos-f129fe34bf7fb114740f8d088e400bd74a97409f.tar.gz
nixos-f129fe34bf7fb114740f8d088e400bd74a97409f.tar.bz2
nixos-f129fe34bf7fb114740f8d088e400bd74a97409f.tar.xz
nixos-f129fe34bf7fb114740f8d088e400bd74a97409f.zip
Jitter backups
-rw-r--r--custom/borgbackup.nix7
1 files changed, 7 insertions, 0 deletions
diff --git a/custom/borgbackup.nix b/custom/borgbackup.nix
index dc40c652..129b5e2e 100644
--- a/custom/borgbackup.nix
+++ b/custom/borgbackup.nix
@@ -46,6 +46,11 @@ let
46 default = "6h"; 46 default = "6h";
47 }; 47 };
48 48
49 jitter = mkOption {
50 type = with types; nullOr str;
51 default = "6h";
52 };
53
49 lock = mkOption { 54 lock = mkOption {
50 type = types.nullOr types.str; 55 type = types.nullOr types.str;
51 default = "backup"; 56 default = "backup";
@@ -102,6 +107,7 @@ in {
102 Persistent = false; 107 Persistent = false;
103 OnBootSec = tCfg.interval; 108 OnBootSec = tCfg.interval;
104 OnUnitInactiveSec = tCfg.interval; 109 OnUnitInactiveSec = tCfg.interval;
110 RandomizedDelaySec = mkIf (tCfg.jitter != null) tCfg.jitter;
105 }; 111 };
106 }) (flatten (mapAttrsToList (target: tCfg: map (path: { inherit target path tCfg; }) tCfg.paths) cfg.targets)))) // (mapAttrs' (target: tCfg: nameValuePair "borgbackup-prune-${target}" { 112 }) (flatten (mapAttrsToList (target: tCfg: map (path: { inherit target path tCfg; }) tCfg.paths) cfg.targets)))) // (mapAttrs' (target: tCfg: nameValuePair "borgbackup-prune-${target}" {
107 enable = tCfg.prune != {}; 113 enable = tCfg.prune != {};
@@ -112,6 +118,7 @@ in {
112 Persistent = false; 118 Persistent = false;
113 OnBootSec = tCfg.interval; 119 OnBootSec = tCfg.interval;
114 OnUnitInactiveSec = tCfg.interval; 120 OnUnitInactiveSec = tCfg.interval;
121 RandomizedDelaySec = mkIf (tCfg.jitter != null) tCfg.jitter;
115 }; 122 };
116 }) cfg.targets); 123 }) cfg.targets);
117 124