diff options
| -rw-r--r-- | custom/borgbackup.nix | 23 | ||||
| -rw-r--r-- | odin.nix | 2 |
2 files changed, 18 insertions, 7 deletions
diff --git a/custom/borgbackup.nix b/custom/borgbackup.nix index 75ff8cde..dabf4200 100644 --- a/custom/borgbackup.nix +++ b/custom/borgbackup.nix | |||
| @@ -99,9 +99,21 @@ in { | |||
| 99 | inherit (path) LV VG; | 99 | inherit (path) LV VG; |
| 100 | mountName = withPrefix (path.VG + "-" + path.LV); | 100 | mountName = withPrefix (path.VG + "-" + path.LV); |
| 101 | }) (unique (flatten (mapAttrsToList (target: tCfg: tCfg.paths) cfg.targets))))); | 101 | }) (unique (flatten (mapAttrsToList (target: tCfg: tCfg.paths) cfg.targets))))); |
| 102 | |||
| 103 | systemd.targets."timers-borg" = { | ||
| 104 | wantedBy = [ "timers.target" ]; | ||
| 105 | }; | ||
| 106 | |||
| 107 | systemd.slices."system-borgbackup" = { | ||
| 108 | sliceConfig = { | ||
| 109 | Nice = 15; | ||
| 110 | IOSchedulingClass = 2; | ||
| 111 | IOSchedulingPriority = 7; | ||
| 112 | }; | ||
| 113 | }; | ||
| 102 | 114 | ||
| 103 | systemd.timers = (listToAttrs (map ({ target, path, tCfg }: nameValuePair "borgbackup-${target}@${systemdPath path}" { | 115 | systemd.timers = (listToAttrs (map ({ target, path, tCfg }: nameValuePair "borgbackup-${target}@${systemdPath path}" { |
| 104 | wantedBy = [ "timers.target" ]; | 116 | requiredBy = [ "timers-borg.target" ]; |
| 105 | 117 | ||
| 106 | timerConfig = { | 118 | timerConfig = { |
| 107 | Persistent = false; | 119 | Persistent = false; |
| @@ -112,7 +124,7 @@ in { | |||
| 112 | }) (flatten (mapAttrsToList (target: tCfg: map (path: { inherit target path tCfg; }) tCfg.paths) cfg.targets)))) // (mapAttrs' (target: tCfg: nameValuePair "borgbackup-prune-${target}" { | 124 | }) (flatten (mapAttrsToList (target: tCfg: map (path: { inherit target path tCfg; }) tCfg.paths) cfg.targets)))) // (mapAttrs' (target: tCfg: nameValuePair "borgbackup-prune-${target}" { |
| 113 | enable = tCfg.prune != {}; | 125 | enable = tCfg.prune != {}; |
| 114 | 126 | ||
| 115 | wantedBy = [ "timers.target" ]; | 127 | requiredBy = [ "timers-borg.target" ]; |
| 116 | 128 | ||
| 117 | timerConfig = { | 129 | timerConfig = { |
| 118 | Persistent = false; | 130 | Persistent = false; |
| @@ -159,10 +171,8 @@ in { | |||
| 159 | serviceConfig = { | 171 | serviceConfig = { |
| 160 | Type = "oneshot"; | 172 | Type = "oneshot"; |
| 161 | WorkingDirectory = if (cfg.snapshots == null) then "%I" else (if (cfg.snapshots == "lvm") then "${mountPoint}/${withPrefix "%I"}" else "${mountPoint}/${withPrefix "%i"}"); | 173 | WorkingDirectory = if (cfg.snapshots == null) then "%I" else (if (cfg.snapshots == "lvm") then "${mountPoint}/${withPrefix "%I"}" else "${mountPoint}/${withPrefix "%i"}"); |
| 162 | Nice = 15; | ||
| 163 | IOSchedulingClass = 2; | ||
| 164 | IOSchedulingPriority = 7; | ||
| 165 | SuccessExitStatus = [1 2]; | 174 | SuccessExitStatus = [1 2]; |
| 175 | Slice = "system-borgbackup"; | ||
| 166 | }; | 176 | }; |
| 167 | })) cfg.targets) // (mapAttrs' (target: tCfg: nameValuePair "borgbackup-prune-${target}" { | 177 | })) cfg.targets) // (mapAttrs' (target: tCfg: nameValuePair "borgbackup-prune-${target}" { |
| 168 | enable = tCfg.prune != {}; | 178 | enable = tCfg.prune != {}; |
| @@ -177,13 +187,14 @@ in { | |||
| 177 | --lock-wait ${toString tCfg.lockWait} \ | 187 | --lock-wait ${toString tCfg.lockWait} \ |
| 178 | --list \ | 188 | --list \ |
| 179 | --stats \ | 189 | --stats \ |
| 180 | --prefix ${escapeShellArg "${cfg.prefix}${if cfg.snapshots == "lvm" then path else escapeSystemdPath path}"} \ | 190 | --prefix ${escapeShellArg "${cfg.prefix}${path}"} \ |
| 181 | ${escapeShellArgs args} \ | 191 | ${escapeShellArgs args} \ |
| 182 | ${tCfg.repo} | 192 | ${tCfg.repo} |
| 183 | '') tCfg.prune); | 193 | '') tCfg.prune); |
| 184 | 194 | ||
| 185 | serviceConfig = { | 195 | serviceConfig = { |
| 186 | Type = "oneshot"; | 196 | Type = "oneshot"; |
| 197 | Slice = "system-borgbackup"; | ||
| 187 | }; | 198 | }; |
| 188 | }) cfg.targets); | 199 | }) cfg.targets); |
| 189 | }; | 200 | }; |
| @@ -201,7 +201,7 @@ | |||
| 201 | ]; | 201 | ]; |
| 202 | 202 | ||
| 203 | prune = lib.genAttrs | 203 | prune = lib.genAttrs |
| 204 | ["raid6/mail" "raid6/home" "raid6/media" "raid6/root" "raid6/git" "ssd-raid1/root"] | 204 | ["raid6-mail" "raid6-home" "raid6-media" "raid6-root" "raid6-git" "ssd-raid1-root"] |
| 205 | (name: [ | 205 | (name: [ |
| 206 | "--keep-within" "24H" | 206 | "--keep-within" "24H" |
| 207 | "--keep-daily" "31" | 207 | "--keep-daily" "31" |
