btrfssnapshot: make it somewhat work

This commit is contained in:
Motiejus Jakštys 2024-07-29 16:11:01 +03:00
parent 43697386b8
commit 7970c36801
5 changed files with 26 additions and 7 deletions

View File

@ -79,6 +79,22 @@ in
verboseLogs = true;
};
btrfssnapshot = {
enable = true;
subvolumes = {
"/home" = {
label = "5minutely";
keep = 12;
refreshInterval = "*:0/5";
};
#"/home" = {
# label = "hourly";
# keep = 24;
# refreshInterval = "*:00:00";
#};
};
};
wifibackup = {
enable = true;
toPath = "/home/${config.mj.username}/M-Active/.wifi";

View File

@ -11,7 +11,6 @@ in
{
imports = [
./boot
./btrfssnapshot
./fileSystems
./snapshot
./sshd

View File

@ -5,10 +5,10 @@
...
}:
let
cfg = config.mj.base.btrfssnapshot;
cfg = config.mj.services.btrfssnapshot;
in
{
options.mj.base.btrfssnapshot = {
options.mj.services.btrfssnapshot = {
enable = lib.mkEnableOption "Enable btrfs snapshots";
subvolumes = lib.mkOption {
@ -30,10 +30,10 @@ in
services = lib.mapAttrs' (
subvolume: params:
lib.nameValuePair "btrfs-snapshot-${lib.strings.sanitizeDerivationName subvolume}" {
description = "${params.label} btrfs snapshot for ${subvolume} (keep ${params.keep}";
serviceConfig.ExecStart = "${pkgs.btrfs-auto-snapshot} --verbose --label=${params.label} --keep=${params.keep} ${subvolume}";
description = "${params.label} btrfs snapshot for ${subvolume} (keep ${builtins.toString params.keep})";
serviceConfig.ExecStart = "${pkgs.btrfs-auto-snapshot}/bin/btrfs-auto-snapshot --verbose --label=${params.label} --keep=${builtins.toString params.keep} ${subvolume}";
}
);
) cfg.subvolumes;
timers = lib.mapAttrs' (
subvolume: params:
@ -42,7 +42,7 @@ in
wantedBy = [ "timers.target" ];
timerConfig.OnCalendar = params.refreshInterval;
}
);
) cfg.subvolumes;
};
};
}

View File

@ -2,6 +2,7 @@
{
imports = [
./borgstor
./btrfssnapshot
./deployerbot
./friendlyport
./gitea

View File

@ -61,6 +61,9 @@ au FileType yaml setlocal ts=2 sw=2 sts=2
au FileType sql setlocal formatprg=pg_format\ -
au FileType sql setlocal ts=2 sw=2 sts=2
" nix
au FileType nix setlocal ts=2 sw=2 sts=2
" mail
autocmd BufRead,BufNewFile *mutt-* setfiletype mail