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;
|
||||
lib.mkIf enable {
|
||||
systemd.services."zfsborg-snapshot-dirs" = {
|
||||
description = "zfsborg prepare snapshot directories";
|
||||
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;
|
||||
systemd.services =
|
||||
lib.listToAttrs (lib.imap1 (
|
||||
i: attr:
|
||||
lib.nameValuePair "borgbackup-job-${lib.strings.sanitizeDerivationName attr.mountpoint}-${toString i}" {
|
||||
serviceConfig.TemporaryFileSystem = "${attr.mountpoint}/.snapshot-latest";
|
||||
}
|
||||
)
|
||||
dirs)
|
||||
// {
|
||||
"zfsborg-snapshot-dirs" = {
|
||||
description = "zfsborg prepare snapshot directories";
|
||||
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 (
|
||||
lib.imap0 (
|
||||
@ -83,7 +93,6 @@ in {
|
||||
extraArgs = "--remote-path=borg1";
|
||||
compression = "auto,lzma";
|
||||
startAt = attrs.backup_at;
|
||||
readWritePaths = let p = mountpoint + "/.snapshot-latest"; in [p];
|
||||
preHook = mountLatest mountpoint fs.device;
|
||||
postHook = umountLatest mountpoint;
|
||||
prune.keep = {
|
||||
|
Loading…
Reference in New Issue
Block a user