From 7855de6a3efd4d5de8093c63c36e2b8d0b016f59 Mon Sep 17 00:00:00 2001 From: dadada Date: Sat, 17 Dec 2022 02:36:12 +0100 Subject: [PATCH] fix backup --- nixos/modules/backup.nix | 46 +++++++++++++++---------------- nixos/modules/profiles/backup.nix | 4 +-- 2 files changed, 24 insertions(+), 26 deletions(-) diff --git a/nixos/modules/backup.nix b/nixos/modules/backup.nix index 44087f0..0adeafe 100644 --- a/nixos/modules/backup.nix +++ b/nixos/modules/backup.nix @@ -58,8 +58,8 @@ in }; }; - config = mkIf cfg.gs.enable { - fileSystems = mkIf cfg.gs { + config = { + fileSystems = mkIf cfg.gs.enable { "/backup" = { device = "/dev/disk/by-uuid/0fdab735-cc3e-493a-b4ec-cbf6a77d48d5"; fsType = "ext4"; @@ -67,8 +67,7 @@ in }; }; - services.borgbackup.jobs.gs = - { + services.borgbackup.jobs.gs = mkIf cfg.gs.enable { paths = "/"; exclude = backupExcludes; repo = "/backup/${config.networking.hostName}"; @@ -86,26 +85,25 @@ in yearly = -1; # Keep at least one archive for each year }; startAt = "monthly"; - } - // mkIf cfg.bs.enable { - services.borgbackup.jobs.bs = { - paths = "/"; - exclude = backupExcludes; - repo = "borg@backup0.dadada.li:/mnt/storage/backup/${config.networking.hostName}"; - doInit = false; - environment = { - BORG_RSH = "ssh -i ${cfg.bs.sshIdentityFile} -o 'StrictHostKeyChecking accept-new' -o 'TCPKeepAlive=yes'"; - }; - encryption = { - mode = "repokey"; - passCommand = "cat ${cfg.bs.passphrasePath}"; - }; - compression = "auto,lz4"; - startAt = "daily"; - environment = { - BORG_RELOCATED_REPO_ACCESS_IS_OK = "yes"; - }; - }; + }; + + services.borgbackup.jobs.bs = mkIf cfg.bs.enable { + paths = "/"; + exclude = backupExcludes; + repo = "borg@backup0.dadada.li:/mnt/storage/backup/${config.networking.hostName}"; + doInit = false; + environment = { + BORG_RSH = "ssh -i ${cfg.bs.sshIdentityFile} -o 'StrictHostKeyChecking accept-new' -o 'TCPKeepAlive=yes'"; }; + encryption = { + mode = "repokey"; + passCommand = "cat ${cfg.bs.passphrasePath}"; + }; + compression = "auto,lz4"; + startAt = "daily"; + environment = { + BORG_RELOCATED_REPO_ACCESS_IS_OK = "yes"; + }; + }; }; } diff --git a/nixos/modules/profiles/backup.nix b/nixos/modules/profiles/backup.nix index dfa3f2e..88dfab5 100644 --- a/nixos/modules/profiles/backup.nix +++ b/nixos/modules/profiles/backup.nix @@ -5,8 +5,8 @@ in { dadada.backupClient.bs = { enable = true; - passphrasePath = config.age.secrets."${config.networking.hostName}-backup-passphrase.path"; - sshIdentityFile = config.age.secrets."${config.networking.hostName}-backup-ssh-key.path"; + passphrasePath = config.age.secrets."${config.networking.hostName}-backup-passphrase".path; + sshIdentityFile = config.age.secrets."${config.networking.hostName}-backup-ssh-key".path; }; age.secrets."${config.networking.hostName}-backup-passphrase".file = "${secretsPath}/${config.networking.hostName}-backup-passphrase.age";