change snapshot dir
This commit is contained in:
parent
afd2398378
commit
2c4598ba7b
@ -6,12 +6,13 @@
|
|||||||
}: let
|
}: let
|
||||||
mkPreHook = mountpoint: zfs_name: ''
|
mkPreHook = mountpoint: zfs_name: ''
|
||||||
set -x
|
set -x
|
||||||
|
mkdir "$RUNTIME_DIRECTORY/snapshot"
|
||||||
${pkgs.util-linux}/bin/mount \
|
${pkgs.util-linux}/bin/mount \
|
||||||
-t zfs \
|
-t zfs \
|
||||||
-o ro \
|
-o ro \
|
||||||
$(${pkgs.zfs}/bin/zfs list -H -t snapshot -o name ${zfs_name} | sort | tail -1) \
|
$(${pkgs.zfs}/bin/zfs list -H -t snapshot -o name ${zfs_name} | sort | tail -1) \
|
||||||
${mountpoint}/.snapshot-latest
|
"$RUNTIME_DIRECTORY/snapshot"
|
||||||
cd ${mountpoint}/.snapshot-latest
|
cd "$RUNTIME_DIRECTORY/snapshot"
|
||||||
'';
|
'';
|
||||||
in {
|
in {
|
||||||
options.mj.base.zfsborg = with lib.types; {
|
options.mj.base.zfsborg = with lib.types; {
|
||||||
@ -44,30 +45,15 @@ in {
|
|||||||
|
|
||||||
config = with config.mj.base.zfsborg;
|
config = with config.mj.base.zfsborg;
|
||||||
lib.mkIf enable {
|
lib.mkIf enable {
|
||||||
systemd.services =
|
systemd.services = lib.listToAttrs (lib.imap0 (
|
||||||
lib.listToAttrs (lib.imap0 (
|
i: attr: let
|
||||||
i: attr:
|
svcName = "borgbackup-job-${lib.strings.sanitizeDerivationName attr.mountpoint}-${toString i}";
|
||||||
lib.nameValuePair "borgbackup-job-${lib.strings.sanitizeDerivationName attr.mountpoint}-${toString i}" {
|
in
|
||||||
serviceConfig.TemporaryFileSystem = "${attr.mountpoint}/.snapshot-latest";
|
lib.nameValuePair svcName {
|
||||||
}
|
serviceConfig.RuntimeDirectory = svcName;
|
||||||
)
|
}
|
||||||
dirs)
|
)
|
||||||
// {
|
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 (
|
services.borgbackup.jobs = builtins.listToAttrs (
|
||||||
lib.imap0 (
|
lib.imap0 (
|
||||||
|
Loading…
Reference in New Issue
Block a user