Dark Developments Where Knowledge Meets Power

25Jul/110

D#B Backup&Recovery Notes [PART5]: Citrix XenServer

Posted by Dark#Basics

Metadata

XenServer Hosts use a per-host database to store metadata about VMs and associated resources such as storage and networking. When combined with storage repositories, this database forms the complete view of all VMs available across the pool. Thus, it is important to understand how to backup this database in order to recover from physical hardware failure and other disaster scenarios.

Backup

In a pool scenario, the master host provides an authoritative database which is synchronously mirrored by all the slave hosts in the pool. This provides a degree of built-in redundancy to a pool; the master can be replaced by any slave since each of them have an accurate version of the pool database.

This level of protection may not be sufficient; for example, if your shared storage containing the VM data is backed up in multiple sites, but your local server storage (containing the pool metadata) is not. To fully recreate a pool given just a set of shared storage, you must first backup the xe pool-dump-database against the master host, and archive this file.

Making a manual backup can be done follow CLI-command from within the pool master.

xe pool-dump-database filename=<filename>

This command can be automated with for example Cron.

Recovery

As for recovering the metadata following CLI-command must be used.

xe pool-dump-database filename=<sourcefilename>

Do note that all of the hosts AND the node will be rolled back.

VMs

Backup

Creating a backup through the CLI can be done with the following command.

xe host-backup file-name=<filename> -h hostname -u root -pw <password>

This can be automated Cron. By using a Bash-script made by Andy Burton it is possible to make a snapshot from all, running, none and specifically (by VM uuid) set VMs.

Recovery

Recovering a VM can be done with both CLI and XenCenter. With XenCenter just use Import VM under File to import the backup image.

Not only the snapshot but also the metadata of the VM will be restored.

If you want to restore a XenServer Host from a specific backup, run the following command while the XenServer Host is up and reachable.

xe host-restore file-name=<filename> -h hostname -u root -pw <password>

This restores the compressed image back to the hard disk of the XenServer Host. In this context “restore” is something of a misnomer, as the word usually suggests that the backed-up state has been put fully in place. The restore command here only unpacks the compressed backup file and restores it to its normal form, but it is written to another partition (/dev/sda2) and does not overwrite the current version of the filesystem.

To actually use the restored version of the root filesystem, you need to reboot the XenServer Host using the XenServer installation CD and select the Restore from backup option.

After the Restore from Backup is completed, reboot the XenServer Host machine and it will start up from the restored image.

Finally, restore the VM meta-data using the xe pool-database-restore command.

Source: