Skip to content

Instantly share code, notes, and snippets.

@mb00g
Created April 12, 2017 08:22
Show Gist options
  • Save mb00g/d4837d91c912b18380ec73a2527bdae9 to your computer and use it in GitHub Desktop.
Save mb00g/d4837d91c912b18380ec73a2527bdae9 to your computer and use it in GitHub Desktop.
Export VM Metadata XenServer
#!/bin/bash
DATE=$(date +%d%B%y)
XSNAME=`echo $HOSTNAME`
BACKUPPATH=/opt/$XSNAME
mkdir -p $BACKUPPATH
xe vm-list is-control-domain=false is-a-snapshot=false | grep uuid | cut -d":" -f2 > /$BACKUPPATH/list-uuids.txt
while read line
do
VMNAME=`xe vm-list uuid=$line | grep name-label | cut -d":" -f2 | sed 's/^ *//g'`
xe vm-export filename="$BACKUPPATH/$VMNAME-$DATE.vmmeta" uuid=$line metadata=true
done < /$BACKUPPATH/list-uuids.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment