diff --git a/common/default.nix b/common/default.nix index 11e5d0a..aed2093 100644 --- a/common/default.nix +++ b/common/default.nix @@ -10,6 +10,7 @@ ./nginx.nix ./nix.nix ./openssh.nix + ./sanoid.nix ./security.nix ./steam.nix ]; diff --git a/common/sanoid.nix b/common/sanoid.nix new file mode 100644 index 0000000..82137e0 --- /dev/null +++ b/common/sanoid.nix @@ -0,0 +1,35 @@ +{ config, pkgs, inputs, ... }: + +{ + config = { + services.sanoid = { + enable = true; + extraArgs = [ "--verbose" ]; + + # Local snapshots for important datasets + templates."production" = { + yearly = 0; + monthly = 3; + daily = 30; + hourly = 36; + autosnap = true; + autoprune = true; + }; + + # Reduced-retention version for datasets that are backed up to the NAS + templates."safe" = { + yearly = 0; + monthly = 0; + daily = 7; + hourly = 24; + autosnap = true; + autoprune = true; + }; + + # datasets."rpool_sggau1/reese/system" = { + # useTemplate = [ "safe" ]; + # recursive = "zfs"; + # }; + }; + }; +} \ No newline at end of file diff --git a/hosts/kilgharrah/backup.nix b/hosts/kilgharrah/backup.nix new file mode 100644 index 0000000..efa72f9 --- /dev/null +++ b/hosts/kilgharrah/backup.nix @@ -0,0 +1,8 @@ +{ config, lib, pkgs, ... }: + +{ + services.sanoid.datasets."rpool_albion/state" = { + useTemplate = [ "production" ]; + recursive = "zfs"; + }; +} \ No newline at end of file diff --git a/hosts/kilgharrah/default.nix b/hosts/kilgharrah/default.nix index 4ac9a04..8f5ef87 100644 --- a/hosts/kilgharrah/default.nix +++ b/hosts/kilgharrah/default.nix @@ -5,6 +5,7 @@ let in { imports = [ + ./backup.nix ./filesystems.nix ./hardware.nix ./networking.nix diff --git a/hosts/orm/default.nix b/hosts/orm/default.nix index 1d8a648..da66828 100644 --- a/hosts/orm/default.nix +++ b/hosts/orm/default.nix @@ -19,6 +19,11 @@ "rpool_orm/state/actual" = { mountpoint = "/var/lib/actual"; }; }; + services.sanoid.datasets."rpool_orm/state" = { + useTemplate = [ "production" ]; + recursive = "zfs"; + }; + qenya.services.actual = { enable = true; domain = "actual.qenya.tel"; diff --git a/hosts/yevaud/default.nix b/hosts/yevaud/default.nix index c2d4639..55faeb1 100644 --- a/hosts/yevaud/default.nix +++ b/hosts/yevaud/default.nix @@ -22,6 +22,11 @@ "rpool/state/forgejo" = { mountpoint = "/var/lib/forgejo"; }; }; + services.sanoid.datasets."rpool/state" = { + useTemplate = [ "production" ]; + recursive = "zfs"; + }; + qenya.services.forgejo = { enable = true; domain = "git.qenya.tel";