From 9e10ba08204a45f55fec5acf59b89432d3a007b1 Mon Sep 17 00:00:00 2001 From: Simon Cornet Date: Wed, 29 Jul 2020 17:36:17 +0200 Subject: [PATCH] [BACKUP] Added ZFS datastore backup script --- FreeBSD/storage/zfs-dataset-backup.bash | 35 +++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 FreeBSD/storage/zfs-dataset-backup.bash diff --git a/FreeBSD/storage/zfs-dataset-backup.bash b/FreeBSD/storage/zfs-dataset-backup.bash new file mode 100644 index 0000000..ade3a7c --- /dev/null +++ b/FreeBSD/storage/zfs-dataset-backup.bash @@ -0,0 +1,35 @@ +#!/usr/local/bin/bash + +## config section +dataset_orig=$1 +dataset_name=$(echo $dataset_orig | sed -e 's/\//-/g') +backup_location="/tank/backup/datasets" +backup_date=`date "+%Y-%m-%d"` +enc_password="supersecretstuff" + +echo "" +echo "################## SNAPSHOT ###################" +echo "Making a snapshot of $dataset_orig" + +## create snapshot +zfs snapshot $dataset_orig@$backup_date + +# backup vm snapshot +echo "" +echo "################## BACKUP VM ##################" +echo "Send snapshot to local backup destination" + +## send snapshot to backup destination +zfs send $dataset_orig@$backup_date | \ +pigz -c -p 4 | \ +openssl enc -aes-256-ctr -a -pbkdf2 -iter 1000 -salt -k $enc_password \ +> $backup_location/$dataset_name-$backup_date.pigz.enc + +## delete snapshot +#sleep 1 +zfs destroy $dataset_orig@$backup_date + +# report done +echo "" +echo "############### ALL DONE THANKS ###############" +echo ""