From 6f3685f5b1290686f36957b044934e5ff2b876fb Mon Sep 17 00:00:00 2001 From: Gabriel Arazas Date: Sun, 10 Jul 2022 05:43:32 +0800 Subject: [PATCH] tasks/backup-archive: use no local archive anymore It is no more than a safety net and an expensive one at that. A dedicated external storage media would be better. Ideally, hosts should have a snapshotting system with btrfs or similar but it is what it is for now. --- .../nixos/tasks/backup-archive/default.nix | 35 ++++++++++++++++--- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/modules/nixos/tasks/backup-archive/default.nix b/modules/nixos/tasks/backup-archive/default.nix index 00a9b2f0..6f39882d 100644 --- a/modules/nixos/tasks/backup-archive/default.nix +++ b/modules/nixos/tasks/backup-archive/default.nix @@ -64,18 +64,45 @@ in { ]; }; + fileSystems."/mnt/archives" = { + device = "/dev/disk/by-partuuid/____CHANGE_THIS_PLEASE____"; + fsType = "btrfs"; + noCheck = true; + options = [ + # These are btrfs-specific mount options which can found in btrfs.5 + # manual page. + "subvol=@" + "noatime" + "compress=zstd:4" + "space_cache=v2" + + # General mount options from mount.5 manual page. + "noauto" + "nofail" + "user" + + # See systemd.mount.5 and systemd.automount.5 manual page for more + # details. + "x-systemd.automount" + "x-systemd.idle-timeout=2" + "x-systemd.device-timeout=2" + ]; + }; + services.borgbackup.jobs = { - local = borgJobCommonSetting { + local-archive = borgJobCommonSetting { patterns = [ config.age.secrets.borg-patterns-local.path config.age.secrets.borg-patterns.path ]; } // { - repo = "/archives/backups"; - startAt = "04/5:00:00"; + doInit = false; + removableDevice = true; + repo = "/mnt/archives/backups"; + startAt = "daily"; }; - local-archive = borgJobCommonSetting { + local-external-drive = borgJobCommonSetting { patterns = [ config.age.secrets.borg-patterns-local.path config.age.secrets.borg-patterns.path