server-configs/shared/modules/zrepl.nix

99 lines
2 KiB
Nix
Raw Normal View History

2024-08-08 17:37:50 +00:00
{ config, lib, pkgs, ... }:
let
inherit (lib) types;
cfg = config.mine.zrepl;
# helpers
zreplFilesystems = lib.listToAttrs (
lib.forEach cfg.datasets (dataset: lib.nameValuePair dataset true)
);
in {
options = {
mine.zrepl = {
enable = lib.mkEnableOption "zrepl snapshot";
datasets = lib.mkOption {
type = types.listOf types.str;
default = [
"rpool/safe<"
2024-08-24 19:21:52 +00:00
"rpool/backup<"
2024-08-08 17:37:50 +00:00
];
};
};
};
config = lib.mkIf cfg.enable {
services.zrepl = {
enable = true;
settings.jobs = [
# push
{
name = "snapjob";
type = "snap";
filesystems = zreplFilesystems;
snapshotting = {
type = "periodic";
interval = "5m";
prefix = "zrepl_";
};
pruning = {
keep = [
{
type = "grid";
regex = "^zrepl_.*";
# 1. keep all snapshots for 30 minutes
# 2. keep one every 15 minutes for 2 hours
# 3. keep one every hour for 1 day
grid = "1x30m(keep=all) | 8x15m | 24x1h";
}
];
};
}
];
};
};
}
# {
# services.zrepl = {
# enable = true;
# settings.jobs = [
# {
# type = "push";
# name = "safesnapshots";
# filesystems = [
# "rpool/safe<"
# ];
# snapshotting = {
# type = "periodic";
# interval = "5m";
# prefix = "zrepl_";
# };
# pruning = {
# keep_sender = [
# {
# type = "grid";
# regex = "^zrepl_.*";
# # 1. keep all snapshots for 30 minutes
# # 2. keep one every 15 minutes for 2 hours
# # 3. keep one every hour for 1 day
# grid = "1x30m(keep=all) | 8x15m | 14x1d";
# }
# ];
# };
# }
# ];
# };
# }