This article describes how to back up metadata for an individual Virtual Machines on Citrix Xen Servers. In this article, you will get step by step instructions for backing up metadata. Also at end of this article, there is a small shell script which can be used for backup metadata for all VMs running on the Xen server.
1. Backup VMs Metadata in Citrix Xenserver
1.1. Find VMs UUID
Use the following command to get list of UUIDs of all vms along with other details. this UUID will be used in next steps.
xe vm-list is-control-domain= falseis-a-snapshot= false
uuid ( RO) : 8ac95696-94f3-83c1-bc89-8bb2603f832b name-label ( RW): test-vm power-state ( RO): running
As per above output test-vm uuid is “8ac95696-94f3-83c1-bc89-8bb2603f832b“.
1.2. Backup Metadata using UUID
After getting UUID of vm, use following command to backup metadata of virtual machine with uuid 8ac95696-94f3-83c1-bc89-8bb2603f832b and create metadata backup file metadata.bak.
xe vm-export filename= metadata.bakuuid= 8ac95696-94f3-83c1-bc89-8bb2603f832bmetadata=true
You have completed vm metadata backup successfully.
2. Script for Backup All VMs Metadata
This is a good option to schedule metadata backup regularly. You can schedule the below script for backup all the vms metadata on Xen server.
How to use script:
2.1 – Copy this script to a file /scripts/metadata-backup.sh in xenserver.
2.2 – This script is using a remote backup server mounted using nfs, You can replace this with your own settings.
2.3 – Execute this script using sh /scripts/metadata-backup.sh.
2.4 – For regular backup schedule this in systems crontab. [Crontab Examples]