Back up and restore hosts and VMs
Whenever possible, leave the installed state of XenServer hosts unaltered. That is, do not install any additional packages or start additional services on XenServer hosts and treat them as appliances. The best way to restore, then, is to reinstall XenServer host software from the installation media. If you have multiple XenServer hosts, the best approach is to configure a TFTP server and appropriate answer files for this purpose. For more information, see Network boot installations.
We recommend that you use a backup solution offered by one of our certified partners. For more information, see Citrix Ready Marketplace.
XenServer Premium Edition customers can take advantage of the faster changed block only backup. For more information, see the changed block tracking documentation.
These solutions are certified by their vendors and not by Cloud Software Group. Support for these backup solutions is provided by the solution vendor.
We recommend that you frequently perform as many of the following backup procedures as possible to recover from possible server and software failure.
To back up pool metadata:
-
Run the command:
xe pool-dump-database file-name=backup <!--NeedCopy-->
-
To restore the database, run the command:
xe pool-restore-database file-name=backup dry-run=true <!--NeedCopy-->
This command checks that the target machine has an appropriate number of appropriately named NICs, which is required for the backup to succeed.
To back up host configuration and software:
-
Run the command:
xe host-backup host=host file-name=hostbackup <!--NeedCopy-->
Notes:
Do not create the backup in the control domain.
The backup procedure can create a large backup file.
To complete a restore, you must reboot to the original install CD.
This data can only be restored to the original machine.
To back up a VM:
-
Ensure that the VM to be backed up is offline.
-
Run the command:
xe vm-export vm=vm_uuid filename=backup <!--NeedCopy-->
Note:
This backup also backs up all of the VM data. When importing a VM, you can specify the storage mechanism to use for the backed-up data.
Warning:
The backup process can take longer to complete as it backs up all of the VM data.
To back up VM metadata only:
Run the command:
xe vm-export vm=vm_uuid filename=backup metadata=true
<!--NeedCopy-->
Back up virtual machine metadata
XenServer hosts use a database on each host to store metadata about VMs and associated resources such as storage and networking. When combined with SRs, this database forms the complete view of all VMs available across the pool. Therefore it is important to understand how to back up this database to recover from physical hardware failure and other disaster scenarios.
This section first describes how to back up metadata for single-host installations, and then for more complex pool setups.
Back up single host installations
Use the CLI to back up the pool database. To obtain a consistent pool metadata backup file, run pool-dump-database
on the XenServer host and archive the resulting file. The backup file contains sensitive authentication information about the pool, so ensure it is securely stored.
To restore the pool database, use the xe pool-restore-database
command from a previous dump file. If your XenServer host has died completely, then you must first do a fresh install, and then run the pool-restore-database
command against the freshly installed XenServer host.
After you restore the pool database, some VMs may still be registered as being Suspended
. However, if the storage repository with the suspended memory state defined in the suspend-VDI-uuid
field, is a local SR, then the SR may not be available as the host has been reinstalled. To reset these VMs back to the Halted
state so that they can start up again, use the xe vm-shutdown vm=vm_name -force
command, or use the xe vm-reset-powerstate vm=vm_name -force
command.
Warning:
XenServer preserves UUIDs of the hosts restored using this method. If you restore to a different physical machine while the original XenServer host is still running, duplicate UUIDs may be present. As a result, XenCenter refuses to connect to the second XenServer host. Pool database backup is not the recommended mechanism for cloning physical hosts. Use the automated installation support instead. For more information, see Install.
Back up pooled installations
In a pool scenario, the pool coordinator provides an authoritative database that is synchronously mirrored to all the pool member hosts. This process provides a level of built-in redundancy to a pool. Any pool member can replace the pool coordinator because each pool member has an accurate version of the pool database. For more information on how to transition a member into becoming a pool coordinator, see Hosts and resource pools.
This level of protection may not be sufficient. For example, when shared storage containing the VM data is backed up in multiple sites, but the local server storage (containing the pool metadata) is not. To re-create a pool given a set of shared storage, you must first back up the pool-dump-database
file on the pool coordinator host, and archive this file. To restore this backup later on a brand new set of hosts:
-
Install a fresh set of XenServer hosts from the installation media, or if applicable, network boot from your TFTP server.
-
Use the
xe pool-restore-database
on the host designated to be the new pool coordinator. -
Run the
xe host-forget
command on the new pool coordinator to remove the old member machines. -
Use the
xe pool-join
command on the member hosts to connect them to the new pool.
Back up XenServer hosts
This section describes the XenServer host control domain backup and restore procedures. These procedures do not back up the storage repositories that house the VMs, but only the privileged control domain that runs Xen and the XenServer agent.
Note:
The privileged control domain is best left as installed, without customizing it with other packages. We recommend that you set up a network boot environment to install XenServer cleanly from the XenServer media as a recovery strategy. Typically, you do not need to back up the control domain, but we recommend that you save the pool metadata (see Back up virtual machine metadata). Consider this backup method as complementary to backing up the pool metadata.
Using the xe commands host-backup
and host-restore
is another approach that you can take. The xe host-backup
command archives the active partition to a file you specify. The xe host-restore
command extracts an archive created by xe host-backup
over the currently inactive disk partition of the host. This partition can then be made active by booting off the installation CD and selecting to restore the appropriate backup.
After completing the steps in the previous section and rebooting the host, ensure that the VM metadata is restored to a consistent state. Run xe pool-restore-database
on /var/backup/pool-database-${DATE}
to restore the VM metadata. This file is created by xe host-backup
using xe pool-dump-database
command before archiving the running filesystem, to snapshot a consistent state of the VM metadata.
To back up your XenServer host:
On a remote host with enough disk space, run the following command
xe host-backup file-name=filename -h hostname -u root -pw password
<!--NeedCopy-->
This command creates a compressed image of the control domain file system. The image is stored in the location specified by the file-name
argument.
To restore a running XenServer host:
-
If you want to restore your 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 <!--NeedCopy-->
This command restores the compressed image back to the hard disk of the XenServer host which runs this command (not the host on which
filename
resides). In this context, “restore” may be a misnomer, as the word usually suggests that the backed-up state has been put fully in place. The restore command only unpacks the compressed backup file and restores it to its normal form. However, it is written to another partition (/dev/sda2
) and does not overwrite the current version of the filesystem. -
To use the restored version of the root filesystem, 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 and it will start up from the restored image.
-
Finally, restore the VM metadata using the following command:
xe pool-restore-database file-name=/var/backup/pool-database-* -h hostname -u root -pw password <!--NeedCopy-->
Note:
Restoring from a backup as described in this section does not destroy the backup partition.
To restart a crashed XenServer host:
If your XenServer host has crashed and is not reachable, use the XenServer installation CD to do an upgrade install. When the upgrade install is complete, reboot the machine and ensure that your host is reachable with XenCenter or remote CLI.
Then proceed with backing up XenServer hosts as describes in this section.
Back up VMs
We recommend that you use a backup solution offered by one of our certified partners. For more information, see Citrix Ready Marketplace.
These solutions are certified by their vendors and not by Cloud Software Group. Support for these backup solutions is provided by the solution vendor.
XenServer Premium Edition customers can take advantage of the faster changed block only backup. For more information, see the Citrix blog about Changed Block Tracking backup APIs.