From 71d1c3f9c295202b73f5ca2a1afb04c23b096a6e Mon Sep 17 00:00:00 2001 From: Jack O'Sullivan Date: Sat, 16 Nov 2024 18:46:09 +0000 Subject: [PATCH] Ensure borgbackup cache / config is persisted --- .../colony/vms/shill/containers/vaultwarden.nix | 2 ++ .../boxes/colony/vms/whale2/minecraft/default.nix | 1 + nixos/modules/tmproot.nix | 14 ++++++++++++++ 3 files changed, 17 insertions(+) diff --git a/nixos/boxes/colony/vms/shill/containers/vaultwarden.nix b/nixos/boxes/colony/vms/shill/containers/vaultwarden.nix index 916c330..f661371 100644 --- a/nixos/boxes/colony/vms/shill/containers/vaultwarden.nix +++ b/nixos/boxes/colony/vms/shill/containers/vaultwarden.nix @@ -99,6 +99,8 @@ in }; borgbackup.jobs.vaultwarden = { + readWritePaths = [ "/var/lib/borgbackup" "/var/cache/borgbackup" ]; + paths = [ vwData ]; repo = "zh2855@zh2855.rsync.net:borg/vaultwarden2"; doInit = true; diff --git a/nixos/boxes/colony/vms/whale2/minecraft/default.nix b/nixos/boxes/colony/vms/whale2/minecraft/default.nix index 158b70c..9eb5560 100644 --- a/nixos/boxes/colony/vms/whale2/minecraft/default.nix +++ b/nixos/boxes/colony/vms/whale2/minecraft/default.nix @@ -123,6 +123,7 @@ in within = "12H"; hourly = 48; }; + readWritePaths = [ "/var/lib/borgbackup" "/var/cache/borgbackup" ]; # Avoid Minecraft poking the files while we back up preHook = rconCommand "save-off"; diff --git a/nixos/modules/tmproot.nix b/nixos/modules/tmproot.nix index 352efdf..f6c6e36 100644 --- a/nixos/modules/tmproot.nix +++ b/nixos/modules/tmproot.nix @@ -540,6 +540,20 @@ in ]; }) (persistSimpleSvc "octoprint") + (mkIf (config.services.borgbackup.jobs != { }) { + my.tmproot.persistence.config.directories = [ + "/var/lib/borgbackup" + "/var/cache/borgbackup" + ]; + + services.borgbackup.package = pkgs.borgbackup.overrideAttrs (o: { + makeWrapperArgs = o.makeWrapperArgs ++ [ + "--set-default BORG_BASE_DIR /var/lib/borgbackup" + "--set-default BORG_CONFIG_DIR /var/lib/borgbackup/config" + "--set-default BORG_CACHE_DIR /var/cache/borgbackup" + ]; + }); + }) ])) ]);