export XenServer snapshot as file via console

I have created a snapshot of a Citrix XenServer virtual machine using XenCenter, and now I would like to save this snapshot as an *.xva file, just as if I right-click on the snapshot icon in XenCenter and choose "Export to file...".

However since the VM has a size of 100 GByte I would rather do this operation from the XenServer console and save it right to a fast NFS mounted volume instead of downloading the VM through a slow network connection.

Please advise how to do this via the console. I spent some time googling but was unable to find a solution for this particular problem.


Once you snapshot a server you can export that snapshot to locally mounted storage such as NFS. Take a look at a free script written by Andy Burton Here:

http://blog.andyburton.co.uk/index.php/2009-08/citrix-xenserver-automated-live-vm-backup-to-windows-cifs-share/

I have cut and pasted the relevant command from his script below.

# Create snapshot

            snapshot=`xe vm-snapshot vm=$uuid new-name-label=backup_$date`
            vm_log[${#vm_log[@]}]="Snapshot: $snapshot"

            # Set as VM not template

            snapshot_template=`xe template-param-set is-a-template=false uuid=$snapshot`
            vm_log[${#vm_log[@]}]="Set as VM"

            # Export

            snapshot_export=`xe vm-export vm=$snapshot filename="$backup_dir$label-$date$backup_ext"`
            vm_log[${#vm_log[@]}]="Export: $snapshot_export"

            # Delete snapshot

            snapshot_delete=`xe vm-uninstall uuid=$snapshot force=true`
            vm_log[${#vm_log[@]}]="Delete Snapshot: $snapshot_delete"

  1. xe snapshot-list (for snapshot uuid)
  2. xe vm-export vm=SNAPSHOT_UUID filename=/mnt/anything