diff --git a/linux/quasar/zfs.nix b/linux/quasar/zfs.nix index aeba4af..c182cde 100644 --- a/linux/quasar/zfs.nix +++ b/linux/quasar/zfs.nix @@ -29,36 +29,31 @@ ]; }; jobs = let - listener_name = "archive"; - in [ - { + archiveBaseName = "archive"; + backupBaseName = "backup"; + pushConfig = name: grid: { type = "push"; - name = "snapshot"; + name = "push-${name}"; connect = { - inherit listener_name; type = "local"; + listener_name = "${name}-listener"; client_identity = config.networking.hostName; }; filesystems."zactive/main/home" = true; send.encrypted = true; - snapshotting = { - type = "periodic"; - prefix = "zrepl-"; - interval = "1h"; - }; + snapshotting.type = "manual"; pruning = { keep_sender = [ { - type = "grid"; + type = "regex"; regex = "^zrepl-.*"; - grid = lib.concatStringsSep " | " ["1x1h(keep=all)" "24x1h" "7x1d" "4x1w"]; } ]; keep_receiver = [ { type = "grid"; regex = "^zrepl-.*"; - grid = lib.concatStringsSep " | " ["1x1h(keep=all)" "30x1d" "52x1w"]; + grid = lib.concatStringsSep " | " grid; } ]; }; @@ -66,17 +61,41 @@ initial = "guarantee_resumability"; incremental = "guarantee_incremental"; }; - } - { + }; + sinkConfig = name: dataset: { type = "sink"; - name = "archive"; + name = "sink-${name}"; serve = { - inherit listener_name; type = "local"; + listener_name = "${name}-listener"; }; - root_fs = "zarchive/snapshot"; + root_fs = dataset; recv.placeholder.encryption = "off"; + }; + in [ + { + type = "snap"; + name = "snapshot"; + filesystems."zactive/main/home" = true; + snapshotting = { + type = "periodic"; + prefix = "zrepl-"; + interval = "1h"; + }; + pruning = { + keep = [ + { + type = "grid"; + regex = "^zrepl-.*"; + grid = lib.concatStringsSep " | " ["1x1h(keep=all)" "24x1h" "7x1d" "4x1w"]; + } + ]; + }; } + (pushConfig archiveBaseName ["1x1h(keep=all)" "30x1d" "52x1w"]) + (pushConfig backupBaseName ["8x13w"]) + (sinkConfig archiveBaseName "zarchive/snapshot") + (sinkConfig backupBaseName "zbackup/snapshot") ]; }; };