bundles/zfs: actually unmount snapshots before trying to destroy them
All checks were successful
bundlewrap/pipeline/head This commit looks good

This commit is contained in:
Franzi 2021-05-16 07:43:31 +02:00
parent 479b730be4
commit 976aa251d1
Signed by: kunsi
GPG key ID: 12E3D2136B818350

View file

@ -6,15 +6,22 @@ run-parts --exit-on-error -- /etc/zfs-snapshot-backup-pre.d
% for dataset in sorted(node.metadata.get('zfs/filesystems_with_backup_snapshots')):
if zfs get type ${dataset}@snapshot-backup >/dev/null 2>&1
mountpoint="/mnt/backup-snapshot${node.metadata['zfs']['datasets'][dataset]['mountpoint']}"
if findmnt "$mountpoint" >/dev/null
then
zfs destroy -f ${dataset}@snapshot-backup
umount "$mountpoint"
fi
zfs snapshot ${dataset}@snapshot-backup
if zfs get type "${dataset}@snapshot-backup" >/dev/null 2>&1
then
zfs destroy "${dataset}@snapshot-backup"
fi
mkdir -p /mnt/backup-snapshot${node.metadata['zfs']['datasets'][dataset]['mountpoint']}
mount -t zfs ${dataset}@snapshot-backup /mnt/backup-snapshot${node.metadata['zfs']['datasets'][dataset]['mountpoint']}
zfs snapshot "${dataset}@snapshot-backup"
mkdir -p "$mountpoint"
mount -t zfs "${dataset}@snapshot-backup" "$mountpoint"
% endfor