From c9544ceabfdb943053cce56f5f2847548869561b Mon Sep 17 00:00:00 2001 From: Kabbone Date: Sat, 14 Jan 2023 20:12:30 +0100 Subject: [PATCH] hosts: move from snapper to btrbk --- hosts/desktop/hardware-configuration.nix | 6 - hosts/nas/hardware-configuration.nix | 198 +++++------------------ 2 files changed, 41 insertions(+), 163 deletions(-) diff --git a/hosts/desktop/hardware-configuration.nix b/hosts/desktop/hardware-configuration.nix index feff657..06646f2 100644 --- a/hosts/desktop/hardware-configuration.nix +++ b/hosts/desktop/hardware-configuration.nix @@ -94,12 +94,6 @@ options = [ "noauto,users,x-systemd.automount,x-systemd.device-timeout=10,soft,timeo=14,x-systemd.idle-timeout=1min,sec=sys,exec,nfsvers=4.2" ]; }; -# fileSystems."/mnt/Pluto" = -# { device = "nas:/Pluto/nix"; -# fsType = "nfs"; -# options = [ "noauto,users,x-systemd.automount,x-systemd.device-timeout=10,soft,timeo=14,x-systemd.idle-timeout=1min,sec=sys,exec,nfsvers=4.2,local_lock=all" ]; -# }; - swapDevices = [ ]; diff --git a/hosts/nas/hardware-configuration.nix b/hosts/nas/hardware-configuration.nix index 174480d..015b5bb 100644 --- a/hosts/nas/hardware-configuration.nix +++ b/hosts/nas/hardware-configuration.nix @@ -44,109 +44,35 @@ fileSystems = [ "/" "/mnt/Pluto" - "/mnt/Mars" +# "/mnt/Mars" ]; }; - services.snapper.configs = { - home = { - subvolume = "/home"; - extraConfig = '' - TIMELINE_CREATE=yes - TIMELINE_CLEANUP=yes - TIMELINE_LIMIT_HOURLY="5" - TIMELINE_LIMIT_DAILY="5" - TIMELINE_LIMIT_WEEKLY="2" - TIMELINE_LIMIT_MONTHLY="2" - TIMELINE_LIMIT_YEARLY="0" - ''; - }; - mars_home = { - subvolume = "/mnt/Mars/Home"; - extraConfig = '' - TIMELINE_CREATE=yes - TIMELINE_CLEANUP=yes - TIMELINE_LIMIT_HOURLY="5" - TIMELINE_LIMIT_DAILY="5" - TIMELINE_LIMIT_WEEKLY="2" - TIMELINE_LIMIT_MONTHLY="2" - TIMELINE_LIMIT_YEARLY="0" - ''; - }; - pluto_backups = { - subvolume = "/mnt/Pluto/Backups"; - extraConfig = '' - TIMELINE_CREATE=yes - TIMELINE_CLEANUP=yes - TIMELINE_LIMIT_HOURLY="0" - TIMELINE_LIMIT_DAILY="3" - TIMELINE_LIMIT_WEEKLY="2" - TIMELINE_LIMIT_MONTHLY="2" - TIMELINE_LIMIT_YEARLY="0" - ''; - }; - pluto_games = { - subvolume = "/mnt/Pluto/Games"; - extraConfig = '' - TIMELINE_CREATE=yes - TIMELINE_CLEANUP=yes - TIMELINE_LIMIT_HOURLY="0" - TIMELINE_LIMIT_DAILY="5" - TIMELINE_LIMIT_WEEKLY="2" - TIMELINE_LIMIT_MONTHLY="2" - TIMELINE_LIMIT_YEARLY="0" - ''; - }; - pluto_it = { - subvolume = "/mnt/Pluto/IT"; - extraConfig = '' - TIMELINE_CREATE=yes - TIMELINE_CLEANUP=yes - TIMELINE_LIMIT_HOURLY="0" - TIMELINE_LIMIT_DAILY="5"hm - TIMELINE_LIMIT_WEEKLY="2" - TIMELINE_LIMIT_MONTHLY="2" - TIMELINE_LIMIT_YEARLY="0" - ''; - }; - pluto_media = { - subvolume = "/mnt/Pluto/Media"; - extraConfig = '' - TIMELINE_CREATE=yes - TIMELINE_CLEANUP=yes - TIMELINE_LIMIT_HOURLY="0" - TIMELINE_LIMIT_DAILY="5" - TIMELINE_LIMIT_WEEKLY="2" - TIMELINE_LIMIT_MONTHLY="2" - TIMELINE_LIMIT_YEARLY="0" - ''; - }; - pluto_pictures = { - subvolume = "/mnt/Pluto/Pictures"; - extraConfig = '' - TIMELINE_CREATE=yes - TIMELINE_CLEANUP=yes - TIMELINE_LIMIT_HOURLY="0" - TIMELINE_LIMIT_DAILY="5" - TIMELINE_LIMIT_WEEKLY="2" - TIMELINE_LIMIT_MONTHLY="2" - TIMELINE_LIMIT_YEARLY="0" - ''; - }; - pluto_rest = { - subvolume = "/mnt/Pluto/Rest"; - extraConfig = '' - TIMELINE_CREATE=yes - TIMELINE_CLEANUP=yes - TIMELINE_LIMIT_HOURLY="0" - TIMELINE_LIMIT_DAILY="5" - TIMELINE_LIMIT_WEEKLY="2" - TIMELINE_LIMIT_MONTHLY="2" - TIMELINE_LIMIT_YEARLY="0" - ''; + services.btrbk = { + instances = { + hf = { + settings = { + incremental = yes; + snapshot_create = "ondemand"; + snapshot_dir = "/mnt/snapshots"; + + snapshot_preserve = "2m 2w 5d 5h"; + snapshot_preserve_min = "latest"; + + onCalender = "hourly"; + volume = { + "/" = { + snapshot_dir = /mnt/snapshots/root; + snapshot_create = "always"; + subvolume = "@home"; + }; + }; + }; + }; }; }; + fileSystems."/" = { device = "/dev/disk/by-label/NIXROOT"; fsType = "btrfs"; @@ -159,12 +85,6 @@ options = [ "compress=zstd,space_cache=v2,ssd,noatime,subvol=@home,discard=async" ]; }; - fileSystems."/home/.snapshots" = - { device = "/dev/disk/by-label/NIXROOT"; - fsType = "btrfs"; - options = [ "compress=zstd,space_cache=v2,ssd,noatime,subvol=@snapshots,discard=async" ]; - }; - fileSystems."/srv" = { device = "/dev/disk/by-label/NIXROOT"; fsType = "btrfs"; @@ -177,66 +97,36 @@ options = [ "compress=zstd,space_cache=v2,ssd,noatime,subvol=@nix,discard=async" ]; }; + fileSystems."/mnt/snapshots/root" = + { device = "/dev/disk/by-label/NIXROOT"; + fsType = "btrfs"; + options = [ "compress=zstd,space_cache=v2,ssd,noatime,subvol=@snapshots,discard=async" ]; + }; + + fileSystems."/mnt/snapshots/Mars" = + { device = "/dev/disk/by-label/NIXROOT"; + fsType = "btrfs"; + options = [ "compress=zstd,space_cache=v2,ssd,noatime,subvol=@snapshots/mars/home,discard=async" ]; + }; + + fileSystems."/mnt/snapshots/Pluto" = + { device = "/dev/disk/by-label/NAS-RAID"; + fsType = "btrfs"; + options = [ "compress=zstd,space_cache=v2,noatime,subvol=@snapshots" ]; + }; + fileSystems."/mnt/Pluto" = { device = "/dev/disk/by-label/NAS-RAID"; fsType = "btrfs"; options = [ "compress=zstd,space_cache=v2,noatime,subvol=@" ]; }; - fileSystems."/mnt/Pluto/.snapshots" = - { device = "/dev/disk/by-label/NAS-RAID"; - fsType = "btrfs"; - options = [ "compress=zstd,space_cache=v2,noatime,subvol=@snapshots" ]; - }; - - fileSystems."/mnt/Pluto/Backups/.snapshots" = - { device = "/dev/disk/by-label/NAS-RAID"; - fsType = "btrfs"; - options = [ "compress=zstd,space_cache=v2,noatime,subvol=@snapshots/Backups" ]; - }; - - fileSystems."/mnt/Pluto/Games/.snapshots" = - { device = "/dev/disk/by-label/NAS-RAID"; - fsType = "btrfs"; - options = [ "compress=zstd,space_cache=v2,noatime,subvol=@snapshots/Games" ]; - }; - - fileSystems."/mnt/Pluto/IT/.snapshots" = - { device = "/dev/disk/by-label/NAS-RAID"; - fsType = "btrfs"; - options = [ "compress=zstd,space_cache=v2,noatime,subvol=@snapshots/IT" ]; - }; - - fileSystems."/mnt/Pluto/Media/.snapshots" = - { device = "/dev/disk/by-label/NAS-RAID"; - fsType = "btrfs"; - options = [ "compress=zstd,space_cache=v2,noatime,subvol=@snapshots/Media" ]; - }; - - fileSystems."/mnt/Pluto/Pictures/.snapshots" = - { device = "/dev/disk/by-label/NAS-RAID"; - fsType = "btrfs"; - options = [ "compress=zstd,space_cache=v2,noatime,subvol=@snapshots/Pictures" ]; - }; - - fileSystems."/mnt/Pluto/Rest/.snapshots" = - { device = "/dev/disk/by-label/NAS-RAID"; - fsType = "btrfs"; - options = [ "compress=zstd,space_cache=v2,noatime,subvol=@snapshots/Rest" ]; - }; - fileSystems."/mnt/Mars" = { device = "/dev/disk/by-label/NIXROOT"; fsType = "btrfs"; options = [ "compress=zstd,space_cache=v2,ssd,noatime,subvol=@nas,discard=async" ]; }; - fileSystems."/mnt/Mars/Home/.snapshots" = - { device = "/dev/disk/by-label/NIXROOT"; - fsType = "btrfs"; - options = [ "compress=zstd,space_cache=v2,ssd,noatime,subvol=@snapshots/mars/Home,discard=async" ]; - }; - fileSystems."/boot" = { device = "/dev/disk/by-label/NIXBOOT"; fsType = "vfat"; @@ -252,12 +142,6 @@ options = [ "bind" ]; }; - fileSystems."/export/Nix" = - { device = "/nix"; - options = [ "bind" ]; - }; - - swapDevices = [ ]; networking = {