39 lines
963 B
Bash
39 lines
963 B
Bash
#!/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
|
|
<<<<<<< HEAD
|
|
#sleep 1
|
|
=======
|
|
>>>>>>> 93e0bfb4f86673a87465d127972c447d7c48cfc0
|
|
zfs destroy $dataset_orig@$backup_date
|
|
|
|
# report done
|
|
echo ""
|
|
echo "############### ALL DONE THANKS ###############"
|
|
echo ""
|