Xenserver 7.0 API PowerShell Backup Running VMs

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:

## 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


Lascia un commento

Inserisci i tuoi dati qui sotto o clicca su un'icona per effettuare l'accesso:

Logo WordPress.com

Stai commentando usando il tuo account WordPress.com. Chiudi sessione / Modifica )

Foto Twitter

Stai commentando usando il tuo account Twitter. Chiudi sessione / Modifica )

Foto di Facebook

Stai commentando usando il tuo account Facebook. Chiudi sessione / Modifica )

Google+ photo

Stai commentando usando il tuo account Google+. Chiudi sessione / Modifica )

Connessione a %s...