From 667bc2e06b522b6f78b5355a184cefc3f68d899c Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Wed, 26 Sep 2018 14:08:57 +0200 Subject: ... --- custom/borgbackup.nix | 23 +++++++++++++++++------ 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 { inherit (path) LV VG; mountName = withPrefix (path.VG + "-" + path.LV); }) (unique (flatten (mapAttrsToList (target: tCfg: tCfg.paths) cfg.targets))))); + + systemd.targets."timers-borg" = { + wantedBy = [ "timers.target" ]; + }; + + systemd.slices."system-borgbackup" = { + sliceConfig = { + Nice = 15; + IOSchedulingClass = 2; + IOSchedulingPriority = 7; + }; + }; systemd.timers = (listToAttrs (map ({ target, path, tCfg }: nameValuePair "borgbackup-${target}@${systemdPath path}" { - wantedBy = [ "timers.target" ]; + requiredBy = [ "timers-borg.target" ]; timerConfig = { Persistent = false; @@ -112,7 +124,7 @@ in { }) (flatten (mapAttrsToList (target: tCfg: map (path: { inherit target path tCfg; }) tCfg.paths) cfg.targets)))) // (mapAttrs' (target: tCfg: nameValuePair "borgbackup-prune-${target}" { enable = tCfg.prune != {}; - wantedBy = [ "timers.target" ]; + requiredBy = [ "timers-borg.target" ]; timerConfig = { Persistent = false; @@ -159,10 +171,8 @@ in { serviceConfig = { Type = "oneshot"; WorkingDirectory = if (cfg.snapshots == null) then "%I" else (if (cfg.snapshots == "lvm") then "${mountPoint}/${withPrefix "%I"}" else "${mountPoint}/${withPrefix "%i"}"); - Nice = 15; - IOSchedulingClass = 2; - IOSchedulingPriority = 7; SuccessExitStatus = [1 2]; + Slice = "system-borgbackup"; }; })) cfg.targets) // (mapAttrs' (target: tCfg: nameValuePair "borgbackup-prune-${target}" { enable = tCfg.prune != {}; @@ -177,13 +187,14 @@ in { --lock-wait ${toString tCfg.lockWait} \ --list \ --stats \ - --prefix ${escapeShellArg "${cfg.prefix}${if cfg.snapshots == "lvm" then path else escapeSystemdPath path}"} \ + --prefix ${escapeShellArg "${cfg.prefix}${path}"} \ ${escapeShellArgs args} \ ${tCfg.repo} '') tCfg.prune); serviceConfig = { Type = "oneshot"; + Slice = "system-borgbackup"; }; }) cfg.targets); }; diff --git a/odin.nix b/odin.nix index 336f1610..9d8efbe5 100644 --- a/odin.nix +++ b/odin.nix @@ -201,7 +201,7 @@ ]; prune = lib.genAttrs - ["raid6/mail" "raid6/home" "raid6/media" "raid6/root" "raid6/git" "ssd-raid1/root"] + ["raid6-mail" "raid6-home" "raid6-media" "raid6-root" "raid6-git" "ssd-raid1-root"] (name: [ "--keep-within" "24H" "--keep-daily" "31" -- cgit v1.2.3