From b57b2293cacd37960e6671cb9a65b9bfc7e94203 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20Schr=C3=B6ter?= Date: Wed, 11 May 2022 19:02:41 +0200 Subject: [PATCH] feat(restic): limit resource usage --- modules/restic.nix | 19 +++++++++++++++++++ services/restic/common.nix | 2 ++ 2 files changed, 21 insertions(+) create mode 100644 modules/restic.nix diff --git a/modules/restic.nix b/modules/restic.nix new file mode 100644 index 0000000..2c5dbad --- /dev/null +++ b/modules/restic.nix @@ -0,0 +1,19 @@ +{ config, lib, pkgs, ... }: + +with lib; + +{ + config = { + systemd.services = mapAttrs' (name: backup: + nameValuePair "restic-backups-${name}" ({ + serviceConfig = { + CPUWeight = 25; + MemoryHigh = "50%"; + MemoryMax = "75%"; + IOWeight = 50; + IOSchedulingClass = "idle"; + IOSchedulingPriority = 7; + }; + })) config.services.restic.backups; + }; +} diff --git a/services/restic/common.nix b/services/restic/common.nix index 04fa699..edf187d 100644 --- a/services/restic/common.nix +++ b/services/restic/common.nix @@ -1,6 +1,8 @@ { config, pkgs, lib, ... }: { + imports = [ ../../modules/restic.nix ]; + age.secrets.restic-b2.file = ../../secrets/restic/b2.age; age.secrets.restic-password.file = ../../secrets/restic/password.age; }