zfsborg: remove the ${mountpoint}/.snapshot-latest prefix

The path in the filesystem is quite clear from the archive name.
This commit is contained in:
Motiejus Jakštys 2023-09-15 11:04:20 +03:00
parent 331ffa9450
commit 7ee6a0de71
2 changed files with 35 additions and 30 deletions

View File

@ -63,15 +63,15 @@
mountpoint = "/var/lib";
repo = "zh2769@zh2769.rsync.net:${config.networking.hostName}.${config.networking.domain}-var_lib";
paths = [
"/var/lib/.snapshot-latest/bitwarden_rs"
"/var/lib/.snapshot-latest/caddy"
"/var/lib/.snapshot-latest/gitea"
"/var/lib/.snapshot-latest/grafana"
"/var/lib/.snapshot-latest/headscale"
"/var/lib/.snapshot-latest/matrix-synapse"
"/var/lib/.snapshot-latest/nsd-acme"
"/var/lib/.snapshot-latest/tailscale"
"/var/lib/.snapshot-latest/private/soju"
"bitwarden_rs"
"caddy"
"gitea"
"grafana"
"headscale"
"matrix-synapse"
"nsd-acme"
"tailscale"
"private/soju"
];
backup_at = "*-*-* 00:01:00";
}
@ -79,15 +79,15 @@
mountpoint = "/var/lib";
repo = "borgstor@${myData.hosts."vno3-rp3b.servers.jakst".jakstIP}:${config.networking.hostName}.${config.networking.domain}-var_lib";
paths = [
"/var/lib/.snapshot-latest/bitwarden_rs"
"/var/lib/.snapshot-latest/caddy"
"/var/lib/.snapshot-latest/gitea"
"/var/lib/.snapshot-latest/grafana"
"/var/lib/.snapshot-latest/headscale"
"/var/lib/.snapshot-latest/matrix-synapse"
"/var/lib/.snapshot-latest/nsd-acme"
"/var/lib/.snapshot-latest/tailscale"
"/var/lib/.snapshot-latest/private/soju"
"bitwarden_rs"
"caddy"
"gitea"
"grafana"
"headscale"
"matrix-synapse"
"nsd-acme"
"tailscale"
"private/soju"
];
backup_at = "*-*-* 00:01:00";
}
@ -96,9 +96,9 @@
{
mountpoint = "/var/log";
repo = "zh2769@zh2769.rsync.net:${config.networking.hostName}.${config.networking.domain}-var_log";
paths = ["/var/log/.snapshot-latest/caddy/"];
paths = ["caddy"];
patterns = [
"+ /var/log/.snapshot-latest/caddy/access-jakstys.lt.log-*.zst"
"+ caddy/access-jakstys.lt.log-*.zst"
"- *"
];
backup_at = "*-*-* 00:02:00";
@ -106,9 +106,9 @@
{
mountpoint = "/var/log";
repo = "borgstor@${myData.hosts."vno3-rp3b.servers.jakst".jakstIP}:${config.networking.hostName}.${config.networking.domain}-var_log";
paths = ["/var/log/.snapshot-latest/caddy/"];
paths = ["caddy"];
patterns = [
"+ /var/log/.snapshot-latest/caddy/access-jakstys.lt.log-*.zst"
"+ caddy/access-jakstys.lt.log-*.zst"
"- *"
];
backup_at = "*-*-* 00:02:00";
@ -119,8 +119,8 @@
mountpoint = "/home";
repo = "zh2769@zh2769.rsync.net:${config.networking.hostName}.${config.networking.domain}-home-motiejus-annex2";
paths = [
"/home/.snapshot-latest/motiejus/annex2"
"/home/.snapshot-latest/motiejus/.config/syncthing"
"motiejus/annex2"
"motiejus/.config/syncthing"
];
backup_at = "*-*-* 00:05:00 UTC";
}
@ -128,8 +128,8 @@
mountpoint = "/home";
repo = "borgstor@${myData.hosts."vno3-rp3b.servers.jakst".jakstIP}:${config.networking.hostName}.${config.networking.domain}-home-motiejus-annex2";
paths = [
"/home/.snapshot-latest/motiejus/annex2"
"/home/.snapshot-latest/motiejus/.config/syncthing"
"motiejus/annex2"
"motiejus/.config/syncthing"
];
backup_at = "*-*-* 00:05:00 UTC";
}

View File

@ -4,9 +4,14 @@
pkgs,
...
}: let
mountLatest = mountpoint: zfs_name: ''
mkPreHook = mountpoint: zfs_name: ''
set -x
exec ${pkgs.util-linux}/bin/mount -t zfs -o ro $(${pkgs.zfs}/bin/zfs list -H -t snapshot -o name ${zfs_name} | sort | tail -1) ${mountpoint}/.snapshot-latest
${pkgs.util-linux}/bin/mount \
-t zfs \
-o ro \
$(${pkgs.zfs}/bin/zfs list -H -t snapshot -o name ${zfs_name} | sort | tail -1) \
${mountpoint}/.snapshot-latest
cd ${mountpoint}/.snapshot-latest
'';
in {
options.mj.base.zfsborg = with lib.types; {
@ -25,7 +30,7 @@ in {
options = {
mountpoint = lib.mkOption {type = path;};
repo = lib.mkOption {type = str;};
paths = lib.mkOption {type = listOf path;};
paths = lib.mkOption {type = listOf str;};
patterns = lib.mkOption {
type = listOf str;
default = [];
@ -87,7 +92,7 @@ in {
extraArgs = "--remote-path=borg1";
compression = "auto,lzma";
startAt = attrs.backup_at;
preHook = mountLatest mountpoint fs.device;
preHook = mkPreHook mountpoint fs.device;
prune.keep = {
within = "1d";
daily = 7;