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 ""