bundlewrap/bundles/zfs/files/backup-pre-hook
2021-05-15 20:32:23 +02:00

21 lines
613 B
Bash

#!/bin/bash
set -euo pipefail
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
then
zfs destroy -f ${dataset}@snapshot-backup
fi
zfs snapshot ${dataset}@snapshot-backup
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']}
% endfor
run-parts --exit-on-error -- /etc/zfs-snapshot-backup-post.d