This shows you the differences between two versions of the page.
virtualization:xenserver:xenserver_backup_cli [2013/04/12 11:12] 127.0.0.1 external edit |
virtualization:xenserver:xenserver_backup_cli [2023/05/15 12:28] (current) gcooper |
||
---|---|---|---|
Line 2: | Line 2: | ||
FIXME Needs testing and updating | FIXME Needs testing and updating | ||
+ | |||
+ | ===== Manual Mode ===== | ||
With XenServer it is possible to create backups of VMs, even if they are running. The process is as follows: | With XenServer it is possible to create backups of VMs, even if they are running. The process is as follows: | ||
Line 40: | Line 42: | ||
< | < | ||
xe vm-uninstall uuid=< | xe vm-uninstall uuid=< | ||
+ | </ | ||
+ | |||
+ | ===== Scripted Mode ===== | ||
+ | |||
+ | < | ||
+ | #!/bin/bash | ||
+ | |||
+ | datum=`date +%Y%b%d` | ||
+ | xsname=`hostname` | ||
+ | uuidfile=/ | ||
+ | mountpoint=/ | ||
+ | backuppath=$mountpoint/ | ||
+ | |||
+ | if [ ! -d $mountpoint/ | ||
+ | mount /dev/sdb1 $mountpoint | ||
+ | mkdir $mountpoint/ | ||
+ | fi | ||
+ | |||
+ | if [ ! -d $mountpoint/ | ||
+ | echo "No mountpoint found. Please check!" | ||
+ | exit 0 | ||
+ | fi | ||
+ | |||
+ | mkdir -p $backuppath | ||
+ | if [ ! -d $backuppath ]; then | ||
+ | echo "No backup path found. Please check!" | ||
+ | exit 0 | ||
+ | fi | ||
+ | |||
+ | xe vm-list is-control-domain=false is-a-snapshot=false | grep uuid | cut -d":" | ||
+ | |||
+ | if [ ! -f $uuidfile ]; then | ||
+ | echo "No UUID file found. Please check!" | ||
+ | exit 0 | ||
+ | fi | ||
+ | |||
+ | while read VMUUID | ||
+ | do | ||
+ | VMNAME=`xe vm-list uuid=$VMUUID | grep name-label | cut -d":" | ||
+ | SNAPUUID=`xe vm-snapshot uuid=$VMUUID new-name-label=" | ||
+ | |||
+ | xe template-param-set is-a-template=false ha-always-run=false uuid=$SNAPUUID | ||
+ | xe vm-export vm=$SNAPUUID filename=$backuppath/ | ||
+ | xe vm-uninstall uuid=$SNAPUUID force=true | ||
+ | |||
+ | done < | ||
+ | |||
+ | umount $mountpoint | ||
+ | |||
+ | exit | ||
</ | </ |