82 lines
2.0 KiB
Bash
82 lines
2.0 KiB
Bash
# mdmxen project - library for xen
|
|
|
|
backup_vm_run_snap(){
|
|
VM_UUID=$1
|
|
VM_NAME=$2
|
|
COMPRESS=$3
|
|
putlog "start backup_vpm_run_snap $VM_NAME"
|
|
|
|
putlog "create snapshot"
|
|
SNAP_UUID=$(xe vm-snapshot uuid=$VM_UUID new-name-label=snap-$VM_NAME)
|
|
ltest_state "create snapshot"
|
|
|
|
putlog "prepare export"
|
|
xe template-param-set is-a-template=false ha-always-run=false uuid=$SNAP_UUID
|
|
ltest_state "prepare export"
|
|
|
|
putlog "export vm"
|
|
xe vm-export vm=$SNAP_UUID filename=$TMP_DIR/$VM_NAME.xva compress=$COMPRESS
|
|
ltest_state "export vm"
|
|
|
|
putlog "delete snapshot"
|
|
xe vm-uninstall uuid=$SNAP_UUID force=true
|
|
ltest_state "delete snapshot"
|
|
putlog "stop backup_vpm_run_snap $VM_NAME"
|
|
}
|
|
|
|
backup_vm_off(){
|
|
VM_UUID=$1
|
|
VM_NAME=$2
|
|
COMPRESS=$3
|
|
putlog "start backup_vm_off $VM_NAME"
|
|
|
|
putlog "shutdown vm $VM_NAME"
|
|
xe vm-shutdown vm=$VM_UUID
|
|
ltest_state "shutdown vm $VM_NAME"
|
|
sleep 60
|
|
|
|
putlog "export vm $VM_NAME"
|
|
xe vm-export vm=$VM_UUID filename=$TMP_DIR/$VM_NAME.xva compress=$COMPRESS
|
|
ltest_state "export vm $VM_NAME"
|
|
|
|
putlog "start vm $VM_NAME"
|
|
xe vm-start vm=$VM_UUID
|
|
ltest_state "run vm $VM_NAME"
|
|
sleep 60
|
|
putlog "stop backup_vm_off $VM_NAME"
|
|
}
|
|
|
|
backup_vm_off_snap(){
|
|
VM_UUID=$1
|
|
VM_NAME=$2
|
|
COMPRESS=$3
|
|
putlog "start backup_vm_off_snap $VM_NAME"
|
|
|
|
putlog "shutdown vm $VM_NAME"
|
|
xe vm-shutdown vm=$VM_UUID
|
|
ltest_state "shutdown vm $VM_NAME"
|
|
sleep 60
|
|
|
|
putlog "create snapshot"
|
|
SNAP_UUID=$(xe vm-snapshot uuid=$VM_UUID new-name-label=snap-$VM_NAME)
|
|
ltest_state "create snapshot"
|
|
|
|
putlog "start vm $VM_NAME"
|
|
xe vm-start vm=$VM_UUID
|
|
ltest_state "run vm $VM_NAME"
|
|
sleep 60
|
|
|
|
putlog "prepare export"
|
|
xe template-param-set is-a-template=false ha-always-run=false uuid=$SNAP_UUID
|
|
ltest_state "prepare export"
|
|
|
|
putlog "export vm"
|
|
xe vm-export vm=$SNAP_UUID filename=$TMP_DIR/$VM_NAME.xva compress=$COMPRESS
|
|
ltest_state "export vm"
|
|
|
|
putlog "delete snapshot"
|
|
xe vm-uninstall uuid=$SNAP_UUID force=true
|
|
ltest_state "delete snapshot"
|
|
|
|
putlog "stop backup_vm_off_snap $VM_NAME"
|
|
} |