Backing Up XenServer Snapshots
I’ve upgraded most of my XenServer instances to version 6.1, so this isn’t as big of a problem as it used to be. With the older version (5.5-ish) there was a problem reclaiming disk space when a snapshot was deleted.
Here are the commands that I use to create and delete snapshots.
This will output a number of entries that look like the following:
uuid ( RO) : 24d5bddb-08a7-2462-ce7b-2111dfbc6d0e name-label ( RW): media power-state ( RO): running
You will want to grab the UUID for use in the next command, which actually creates the snapshot, and outputs the UUID of the snapshot (which you will want to get for further commands)
xe vm-snapshot vm=24d5bddb-08a7-2462-ce7b-2111dfbc6d0e new-name-label=media_2013_06_24 > 0074f681-7c62-5ee7-4971-d8f61a4960ea
I then execute the following commands. First identifying the snapshot as not being a template. And secondly, exporting the snapshot (as an XVA) to the backup location.
xe template-param-set is-a-template=false uuid=0074f681-7c62-5ee7-4971-d8f61a4960ea xe vm-export vm=0074f681-7c62-5ee7-4971-d8f61a4960ea filename=/backups/media_2013_06_24.xva
Finally, you can delete the snapshot and reclaim the disk space.
xe vm-uninstall uuid=0074f681-7c62-5ee7-4971-d8f61a4960ea force=true