add btrbk system snapshots
This commit is contained in:
53
modules/nixos/my_btrbk/default.nix
Normal file
53
modules/nixos/my_btrbk/default.nix
Normal file
@@ -0,0 +1,53 @@
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
let
|
||||
cfg = config.my_btrbk;
|
||||
inherit (lib) mkEnableOption mkIf mkOption;
|
||||
types = lib.types;
|
||||
in
|
||||
{
|
||||
options.my_btrbk = {
|
||||
enable = mkEnableOption "Btrbk backups";
|
||||
sshKeyFile = mkOption {
|
||||
type = types.nonEmptyStr;
|
||||
};
|
||||
sshUser = mkOption {
|
||||
type = types.nonEmptyStr;
|
||||
default = "btrbk";
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
services.btrbk.instances."remote_falcon" = {
|
||||
onCalendar = "daily";
|
||||
settings = {
|
||||
ssh_identity = cfg.sshKeyFile;
|
||||
ssh_user = cfg.sshUser;
|
||||
|
||||
incremental = "yes";
|
||||
stream_compress = "zstd";
|
||||
stream_compress_level = "3";
|
||||
target_preserve_min = "no";
|
||||
target_preserve = "5d 4w 6m";
|
||||
|
||||
subvolume = {
|
||||
"/" = {
|
||||
snapshot_name = "root";
|
||||
};
|
||||
"/home" = {
|
||||
snapshot_name = "home";
|
||||
};
|
||||
"/nix" = {
|
||||
snapshot_name = "nix";
|
||||
};
|
||||
};
|
||||
snapshot_dir = "/.btrbk_snapshots";
|
||||
target = "send-receive ssh://10.0.0.5/zpool-backup/backups/${config.networking.hostName}";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user