zfsborg: mount the tmpfs on all units
This commit is contained in:
parent
317141fefb
commit
30426ad89e
@ -5,14 +5,8 @@
|
|||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
mountLatest = mountpoint: zfs_name: ''
|
mountLatest = mountpoint: zfs_name: ''
|
||||||
set -euo pipefail
|
set -x
|
||||||
${pkgs.util-linux}/bin/umount ${mountpoint}/.snapshot-latest &>/dev/null || :
|
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
|
||||||
mkdir -p ${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
|
|
||||||
'';
|
|
||||||
|
|
||||||
umountLatest = mountpoint: ''
|
|
||||||
exec ${pkgs.util-linux}/bin/umount ${mountpoint}/.snapshot-latest
|
|
||||||
'';
|
'';
|
||||||
in {
|
in {
|
||||||
options.mj.base.zfsborg = with lib.types; {
|
options.mj.base.zfsborg = with lib.types; {
|
||||||
@ -46,7 +40,7 @@ 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.imap1 (
|
lib.listToAttrs (lib.imap0 (
|
||||||
i: attr:
|
i: attr:
|
||||||
lib.nameValuePair "borgbackup-job-${lib.strings.sanitizeDerivationName attr.mountpoint}-${toString i}" {
|
lib.nameValuePair "borgbackup-job-${lib.strings.sanitizeDerivationName attr.mountpoint}-${toString i}" {
|
||||||
serviceConfig.TemporaryFileSystem = "${attr.mountpoint}/.snapshot-latest";
|
serviceConfig.TemporaryFileSystem = "${attr.mountpoint}/.snapshot-latest";
|
||||||
@ -94,7 +88,6 @@ in {
|
|||||||
compression = "auto,lzma";
|
compression = "auto,lzma";
|
||||||
startAt = attrs.backup_at;
|
startAt = attrs.backup_at;
|
||||||
preHook = mountLatest mountpoint fs.device;
|
preHook = mountLatest mountpoint fs.device;
|
||||||
postHook = umountLatest mountpoint;
|
|
||||||
prune.keep = {
|
prune.keep = {
|
||||||
within = "1d";
|
within = "1d";
|
||||||
daily = 7;
|
daily = 7;
|
||||||
|
Loading…
Reference in New Issue
Block a user