bundles/zfs: actually unmount snapshots before trying to destroy them
All checks were successful
bundlewrap/pipeline/head This commit looks good
All checks were successful
bundlewrap/pipeline/head This commit looks good
This commit is contained in:
parent
479b730be4
commit
976aa251d1
1 changed files with 12 additions and 5 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue