The script backups one or more virtual machines on one or more Xenserver hosts. The configuration of virtual machine to backup is read from an xml file.
This is the gist on github:
https://gist.github.com/nikiink/cdc687d1bbe227e5cfa3e5759c7f7214
## EQUIVALENT BASH SCRIPT: ## SNAPUUID=`xe vm-snapshot uuid=$VMUUID new-name-label="SNAPSHOT-$VMUUID-$DATE"` ## xe template-param-set is-a-template=false ha-always-run=false uuid=${SNAPUUID} ## xe vm-export vm=${SNAPUUID} filename="$BACKUPPATH/$VMNAME-$DATE.xva" ## xe vm-uninstall uuid=${SNAPUUID} force=true Import-Module XenServerPSModule Connect-XenServer -url https://$XENHOST $XENUSER $XENPASSWORD #Create temporary snapshot for hot backup (choose unique name for snapshot) Invoke-XenVM -Name "Xenial Test" -XenAction Snapshot -NewName "Xenial Test Snapshot" $snapshot = Get-XenVM -Name "Xenial Test Snapshot" #Set is-a-template and ha-always-run to false Set-XenVM -Uuid $snapshot.uuid -IsATemplate $false -HaAlwaysRun $false #Export snapshot (path is on the server where this script runs) Export-XenVM -Uuid $snapshot.uuid -XenHost $XENHOST -Path 'C:\Users\Administrator\Documents\Xenial Test.xva' #Destroy Snapshot Remove-XenVM -Uuid $snapshot.uuid Disconnect-XenServer