Server: XenServer 7.1

Management: XenCenter

Goal: Have a Scheduled Snapshot saved to an external drive connected to the server via USB

Issue: The server recognizes the external drive as a removable storage repository but I'm unable to find where to set it as a default location for snapshots.

  • Does scheduling a copy via cron and the host itself would be a better solution ? – yagmoth555 Oct 11 '18 at 12:46
  • 1
    Yeah, came up with a similar idea. I'll answer the question on my own tomorrow with the script I've wrote. It is still bugging a bit, but almost working. BRB – Bert Oct 11 '18 at 15:16

So here is the code I've created. This runs every day at 4am via the cron of the SUDO


datum=`date +%Y%b%d`

if [ ! -d $mountpoint/vms ]; then
 mount /dev/sdb1 $mountpoint
 mkdir $mountpoint/vms

if [ ! -d $mountpoint/vms ]; then
 echo "No mountpoint found. Please check!"
 exit 0

mkdir -p $backuppath
if [ ! -d $backuppath ]; then
 echo "No backup path found. Please check!"
 exit 0

xe vm-list is-control-domain=false is-a-snapshot=false | grep uuid | cut -d":" -f2 > $uuidfile

if [ ! -f $uuidfile ]; then
 echo "No UUID file found. Please check!"
 exit 0

while read VMUUID
  VMNAME=`xe vm-list uuid=$VMUUID | grep name-label | cut -d":" -f2 | sed 's/^ *//g'`
  SNAPUUID=`xe vm-snapshot uuid=$VMUUID new-name-label="SNAPSHOT-$VMNAME-$datum"` 

  xe template-param-set is-a-template=false ha-always-run=false uuid=$SNAPUUID
  xe vm-export vm=$SNAPUUID filename=$backuppath/SNAPSHOT-$VMNAME-$datum.xva
  xe vm-uninstall uuid=$SNAPUUID force=true

done <$uuidfile

umount $mountpoint


Enjoy! :)

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.