From b7378d38dec478418f1d644a8eee9b306a1d0f9e Mon Sep 17 00:00:00 2001 From: oddlama Date: Mon, 4 Dec 2023 22:31:02 +0100 Subject: [PATCH] feat(ward): local snapshotting via zrepl --- hosts/ward/fs.nix | 65 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/hosts/ward/fs.nix b/hosts/ward/fs.nix index 1e91b34..11b18a5 100644 --- a/hosts/ward/fs.nix +++ b/hosts/ward/fs.nix @@ -32,5 +32,70 @@ }; }; + services.zrepl = { + enable = true; + settings = { + global = { + logging = [ + { + type = "syslog"; + level = "info"; + format = "human"; + } + ]; + # TODO zrepl monitor + #monitoring = [ + # { + # type = "prometheus"; + # listen = ":9811"; + # listen_freebind = true; + # } + #]; + }; + + jobs = [ + { + name = "local-snapshots"; + type = "snap"; + filesystems = { + "rpool/local/state<" = true; + "rpool/safe<" = true; + }; + snapshotting = { + type = "periodic"; + prefix = "zrepl-"; + timestamp_format = "iso-8601"; + interval = "15m"; + }; + pruning.keep = [ + # Keep all manual snapshots + { + type = "regex"; + regex = "^zrepl-.*$"; + negate = true; + } + # Keep last n snapshots + { + type = "last_n"; + regex = "^zrepl-.*$"; + count = 10; + } + # Prune periodically + { + type = "grid"; + regex = "^zrepl-.*$"; + grid = lib.concatStringsSep " | " [ + "72x1h" + "90x1d" + "60x1w" + "24x30d" + ]; + } + ]; + } + ]; + }; + }; + boot.initrd.luks.devices.enc-rpool.allowDiscards = true; }