zfsborg: use TemporaryFileSystem for temp snapshots
Otherwise: Sep 13 00:01:05 vno1-oh2 systemd[1]: Started BorgBackup job -var-lib-1. Sep 13 00:01:06 vno1-oh2 borgbackup-job--var-lib-1-start[329228]: filesystem 'rpool/nixos/var/lib@autosnap_2023-09-12_21:00:06_hourly' is already mounted Sep 13 00:01:06 vno1-oh2 borgbackup-job--var-lib-1-start[329209]: umount: /var/lib/.snapshot-latest: not mounted. Sep 13 00:01:06 vno1-oh2 systemd[1]: borgbackup-job--var-lib-1.service: Main process exited, code=exited, status=32/n/a Sep 13 00:01:06 vno1-oh2 systemd[1]: borgbackup-job--var-lib-1.service: Failed with result 'exit-code'. Sep 13 00:01:06 vno1-oh2 systemd[1]: borgbackup-job--var-lib-1.service: Triggering OnFailure= dependencies.
This commit is contained in:
parent
6bdaca4095
commit
00a6a27b92
@ -45,20 +45,30 @@ in {
|
|||||||
|
|
||||||
config = with config.mj.base.zfsborg;
|
config = with config.mj.base.zfsborg;
|
||||||
lib.mkIf enable {
|
lib.mkIf enable {
|
||||||
systemd.services."zfsborg-snapshot-dirs" = {
|
systemd.services =
|
||||||
description = "zfsborg prepare snapshot directories";
|
lib.listToAttrs (lib.imap1 (
|
||||||
wantedBy = ["multi-user.target"];
|
i: attr:
|
||||||
serviceConfig = {
|
lib.nameValuePair "borgbackup-job-${lib.strings.sanitizeDerivationName attr.mountpoint}-${toString i}" {
|
||||||
Type = "oneshot";
|
serviceConfig.TemporaryFileSystem = "${attr.mountpoint}/.snapshot-latest";
|
||||||
ExecStart = let
|
}
|
||||||
mountpoints = lib.unique (lib.catAttrs "mountpoint" dirs);
|
)
|
||||||
in
|
dirs)
|
||||||
builtins.map
|
// {
|
||||||
(d: "${pkgs.coreutils}/bin/mkdir -p ${d}/.snapshot-latest")
|
"zfsborg-snapshot-dirs" = {
|
||||||
mountpoints;
|
description = "zfsborg prepare snapshot directories";
|
||||||
RemainAfterExit = true;
|
wantedBy = ["multi-user.target"];
|
||||||
|
serviceConfig = {
|
||||||
|
Type = "oneshot";
|
||||||
|
ExecStart = let
|
||||||
|
mountpoints = lib.unique (lib.catAttrs "mountpoint" dirs);
|
||||||
|
in
|
||||||
|
builtins.map
|
||||||
|
(d: "${pkgs.coreutils}/bin/mkdir -p ${d}/.snapshot-latest")
|
||||||
|
mountpoints;
|
||||||
|
RemainAfterExit = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
|
||||||
|
|
||||||
services.borgbackup.jobs = builtins.listToAttrs (
|
services.borgbackup.jobs = builtins.listToAttrs (
|
||||||
lib.imap0 (
|
lib.imap0 (
|
||||||
@ -83,7 +93,6 @@ in {
|
|||||||
extraArgs = "--remote-path=borg1";
|
extraArgs = "--remote-path=borg1";
|
||||||
compression = "auto,lzma";
|
compression = "auto,lzma";
|
||||||
startAt = attrs.backup_at;
|
startAt = attrs.backup_at;
|
||||||
readWritePaths = let p = mountpoint + "/.snapshot-latest"; in [p];
|
|
||||||
preHook = mountLatest mountpoint fs.device;
|
preHook = mountLatest mountpoint fs.device;
|
||||||
postHook = umountLatest mountpoint;
|
postHook = umountLatest mountpoint;
|
||||||
prune.keep = {
|
prune.keep = {
|
||||||
|
Loading…
Reference in New Issue
Block a user