From 004820f5083512f58d6ed9d99230158d67890583 Mon Sep 17 00:00:00 2001 From: Ingolf Wagner Date: Fri, 17 Jan 2020 22:35:43 +1300 Subject: [PATCH] backup: backup to external hard drive --- configs/workhorse/hardware-configuration.nix | 21 ++++++++++++++++++++ configs/workhorse/restic.nix | 4 ++-- system/all/restic.nix | 4 ++-- system/desktop/restic.nix | 6 +++--- system/server/restic.nix | 6 +++--- 5 files changed, 31 insertions(+), 10 deletions(-) diff --git a/configs/workhorse/hardware-configuration.nix b/configs/workhorse/hardware-configuration.nix index 7bc601d..e1ebe67 100644 --- a/configs/workhorse/hardware-configuration.nix +++ b/configs/workhorse/hardware-configuration.nix @@ -89,6 +89,27 @@ in { where = "/media"; }]; }) + + (let backupUUID = "f7fa1c0e-ac9f-4955-b4bd-644c1ddb0d89"; + in { + fileSystems."/backup" = { + device = "/dev/disk/by-uuid/${backupUUID}"; + fsType = "ext4"; + options = [ + "nofail" + "noauto" + #"x-systemd.device-timeout=1ms" + ]; + }; + systemd.mounts = [{ + enable = true; + options = "nofail,noauto"; + type = "ext4"; + wantedBy = [ "multi-user.target" ]; + what = "/dev/disk/by-uuid/${backupUUID}"; + where = "/backup"; + }]; + }) ]; } diff --git a/configs/workhorse/restic.nix b/configs/workhorse/restic.nix index 1a7d601..9896512 100644 --- a/configs/workhorse/restic.nix +++ b/configs/workhorse/restic.nix @@ -1,8 +1,8 @@ { config, ... }: { backup.services.restic = { - "on-porani".enable = false; - "on-workhorse".enable = true; + "on-porani.private".enable = false; + "on-workhorse.private".enable = true; }; } diff --git a/system/all/restic.nix b/system/all/restic.nix index c413c59..0501d2a 100644 --- a/system/all/restic.nix +++ b/system/all/restic.nix @@ -8,7 +8,7 @@ }; config = let - servers = [ "porani" "workhorse" "workout" ]; + servers = [ "porani.private" "workhorse.private" "workout.private" ]; dirs = config.backup.all.restic.dirs; setup = server: { @@ -44,7 +44,7 @@ in { backup.services.restic = lib.zipAttrsWith (name: vals: lib.head vals) - (map (server: { "on-${server}" = setup "${server}.private"; }) servers); + (map (server: { "on-${server}" = setup server; }) servers); environment.etc."info/restic-${hostname}.json" = { enable = true; diff --git a/system/desktop/restic.nix b/system/desktop/restic.nix index 5209fd4..5cfc685 100644 --- a/system/desktop/restic.nix +++ b/system/desktop/restic.nix @@ -1,9 +1,9 @@ { backup.services.restic = { - "on-porani".enable = true; - "on-workhorse".enable = true; - "on-workout".enable = true; + "on-porani.private".enable = true; + "on-workhorse.private".enable = true; + "on-workout.private".enable = true; }; backup.all.restic.dirs = [ "/home/palo/.password-store" ]; diff --git a/system/server/restic.nix b/system/server/restic.nix index f6032e4..123e5af 100644 --- a/system/server/restic.nix +++ b/system/server/restic.nix @@ -1,9 +1,9 @@ { lib, ... }: { backup.services.restic = { - "on-porani".enable = lib.mkDefault true; - "on-workhorse".enable = lib.mkDefault true; - "on-workout".enable = lib.mkDefault true; + "on-porani.private".enable = lib.mkDefault true; + "on-workhorse.private".enable = lib.mkDefault true; + "on-workout.private".enable = lib.mkDefault true; }; }