125
On the XenServer host menu-driven text console, under the Backup, Update and Restore menu there
are options which provide a more user-friendly interface to these scripts. The operations should only be
performed on the pool master. You can use these menu options to perform 3 operations:
Schedule a regular metadata backup to the default pool SR, either daily, weekly or monthly. This will
regularly rotate metadata backups and ensure that the latest metadata is present for that SR without any
user intervention being required.
Trigger an immediate metadata backup to the SR of your choice. This will create a backup VDI if
necessary, and attach it to the host and backup all the metadata to that SR. Use this option if you have
made some changes which you want to see reflected in the backup immediately.
Perform a metadata restoration operation. This will prompt you to choose an SR to restore from, and then
the option of restoring only VM records associated with that SR, or all the VM records found (potentially
from other SRs which were present at the time of the backup). There is also a dry run option to see which
VMs would be imported, but not actually perform the operation.
For automating this scripting, there are some commands in the control domain which provide an interface
to metadata backup and restore at a lower level than the menu options:
xe-backup-metadata provides an interface to create the backup VDIs (with the -c flag), and also to attach
the metadata backup and examine its contents.
xe-restore-metadata can be used to probe for a backup VDI on a newly attached SR, and also selectively
reimport VM metadata to recreate the associations between VMs and their disks.
Full usage information for both scripts can be obtained by running them in the control domain using the -h
flag. One particularly useful invocation mode is xe-backup-metadata -d which mounts the backup VDI into
dom0, and drops into a sub-shell with the backup directory so it can be examined.
Moving SRs between hosts and Pools
The metadata backup and restore options can be run as scripts in the control domain or through the Backup,
Restore, and Update menu option in the xsconsole. All other actions, such as detaching the SR from the
source host and attaching it to the destination host, can be performed using XenCenter, the menu-based
xsconsole, or the xe CLI. This example uses a combination of XenCenter and xsconsole.

To create and move a portable SR using the xsconsole and XenCenter

1. On the source host or pool, in xsconsole, select the Backup, Restore, and Update menu option, select
the Backup Virtual Machine Metadata option, and then select the desired SR.
2. In XenCenter, select the source host or pool and shutdown all running VMs with VDIs on the SR to
be moved.
3. In the tree view select the SR to be moved and select Storage > Detach Storage Repository. The
Detach Storage Repository menu option will not be displayed if there are running VMs with VDIs on
the selected SR. After being detached the SR will be displayed in a grayed-out state.
Warning:
Do not complete this step unless you have created a backup VDI in step 1.
4. Select Storage > Forget Storage Repository to remove the SR record from the host or pool.
5. Select the destination host in the tree view and select Storage > New Storage Repository.
6. Create a new SR with the appropriate parameters required to reconnect the existing SR to the
destination host. In the case of moving a SR between pools or hosts within a site the parameters may
be identical to the source pool.