[VMBACKUP] Added single VM backup file
This commit is contained in:
parent
29b3a7b163
commit
2aba6a4255
47
FreeBSD/vm-backup-single
Normal file
47
FreeBSD/vm-backup-single
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
#!/bin/csh
|
||||||
|
|
||||||
|
## config section
|
||||||
|
set vm = $1
|
||||||
|
set vm_dataset = "zroot/vms"
|
||||||
|
set backup_dataset = "tank/backup/bhyve"
|
||||||
|
set backup_date = `date "+%Y-%m-%d_%H:%M"`
|
||||||
|
|
||||||
|
# Snapshot all VMs
|
||||||
|
echo ""
|
||||||
|
echo "################# SNAPSHOT VM #################"
|
||||||
|
|
||||||
|
## stopping vm
|
||||||
|
vm stop $vm
|
||||||
|
|
||||||
|
## give vm time to shut down properly
|
||||||
|
sleep 15
|
||||||
|
|
||||||
|
## snapshot vm
|
||||||
|
echo "Snapshot VM: $vm"
|
||||||
|
zfs snapshot $vm_dataset/$vm@$backup_date
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
## start VM
|
||||||
|
vm start $vm
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
# Backup all VM snapshots
|
||||||
|
echo ""
|
||||||
|
echo "################## BACKUP VM ##################"
|
||||||
|
|
||||||
|
## Create ZFS dataset
|
||||||
|
echo "Creating destination dataset for $vm"
|
||||||
|
zfs create $backup_dataset/$vm-$backup_date
|
||||||
|
|
||||||
|
## Send snapshot to backup destination
|
||||||
|
echo "Backup VM: $vm"
|
||||||
|
zfs send $vm_dataset/$vm@$backup_date | zfs recv -F $backup_dataset/$vm-$backup_date
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
## Delete snapshot
|
||||||
|
zfs destroy $vm_dataset/$vm@$backup_date
|
||||||
|
|
||||||
|
# report done
|
||||||
|
echo ""
|
||||||
|
echo "############### ALL DONE THANKS ###############"
|
||||||
|
echo ""
|
Loading…
Reference in New Issue
Block a user