[BACKUP] Added ZFS datastore backup script
This commit is contained in:
parent
0602bb03ee
commit
9e10ba0820
35
FreeBSD/storage/zfs-dataset-backup.bash
Normal file
35
FreeBSD/storage/zfs-dataset-backup.bash
Normal file
@ -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 ""
|
Loading…
Reference in New Issue
Block a user