98 lines
2 KiB
Nix
98 lines
2 KiB
Nix
|
{ 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<"
|
||
|
];
|
||
|
};
|
||
|
};
|
||
|
};
|
||
|
|
||
|
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";
|
||
|
# }
|
||
|
# ];
|
||
|
# };
|
||
|
# }
|
||
|
# ];
|
||
|
# };
|
||
|
# }
|