Importing a Xen VM from a .xva file
Import/Restore a Xen VM from a backed-up image file, likely a backup taken of a VM prior to the destruction of said VM for any reason.
Import via command line (faster and preferred method)
This method took 2:33 (2 minutes 33 seconds) to import a VM that had an 8GB HDD, of which 6 GB was used
-
Ensure you have mounted the location with the .xva file. For instance, if it is a remote NFS store, you may want to check the current mount points, or execute:
mount -t nfs 10.1.1.250:/mnt/backups/xenbackups /mnt/backup
-
Take note of the filename & path that you will use for restoration/import, such as:
/mnt/backup/Test-VM-2016-02-17_12-23-01.xva
-
If you don’t have shared storage in your Xen Pool, or if you wish to place the VM on a specific server or Storage Repository (SR), execute the command:
xe sr-list
which will produce output such as this:
uuid ( RO): 73a394e5-2a60-a13d-9c42-4987d81c1a77 name-label ( RW): DVD drives name-description ( RW): Physical DVD drives host ( RO): XEN-SRV-4 type ( RO): udev content-type ( RO): iso uuid ( RO): 3b3346b2-d08a-90a8-bc13-321e0fe988d9 name-label ( RW): Removable storage name-description ( RW): host ( RO): XEN-SRV-4 type ( RO): udev content-type ( RO): disk uuid ( RO): 69659292-ca18-3875-8c3b-1c9873db1dc0 name-label ( RW): Local storage name-description ( RW): host ( RO): XEN-SRV-4 type ( RO): lvm content-type ( RO): user
Take note of the uuid of the “
Local Storage
” of the host on which you wish to place the VM. In this case, if we want to place the VM on “XEN-SRV-4
,” then we will need the uuid “69659292-ca18-3875-8c3b-1c9873db1dc0
“ -
Using the uuid & filename from above, you can then execute the vm-import command thus, preferably on the physical host where you are importing the VM, to minimize network traffic and potential slowdowns caused by passing packets from one server to another unnecessarily:
xe vm-import filename=/mnt/backup/Test-VM-2016-02-17_12-23-01.xva sr-uuid=69659292-ca18-3875-8c3b-1c9873db1dc0
If you want or need to retain the VIF MAC addresses (such as for a VM that gets its IP Address via DHCP), ensure that you specify the
preserve=true
option such as:xe vm-import filename=/mnt/backup/Test-VM-2016-02-17_12-23-01.xva sr-uuid=69659292-ca18-3875-8c3b-1c9873db1dc0 preserve=true
-
If you wish to have the VM start automatically when the Hypervisor/Host boots, ensure you re-enable the autostart option, as it does not get restored when importing a VM from a file. For that, you’ll need the uuid of the VM (
xe vm-list
can help you there) and then you need to execute:xe vm-param-set uuid=<UUID-OF-VM> other-config:auto_poweron=true
Import via Windows XenCenter GUI (slower method)
This method took 22:40 (22 minutes 40 seconds) to import a VM that had an 8GB HDD, of which 6 GB was used, an order of magnitude slower than the command-line method above
-
First, map a drive to the location with the backups (For instance, map X: to \\backups.my.domain\xenbackups) which you can optionally do via the GUI, or with command line:
net use x: \\backups.my.domain\xenbackups /user:<USERNAME>
-
Take note of the filename & path that you will use for restoration/import, such as:
X:\Test-VM-2016-02-17_12-23-01.xva
-
Right-click on the physical host you wish to place the VM onto (such as XEN-SRV-4), then select Import…
-
Click Browse… to select the file containing the image you wish you import (X:\Test-VM-2016-02-17_12-23-01.xva) then click Next
-
Select the Home Server for the VM (XEN-SRV-4 in this case), then click Next
-
Select the storage for the VM HDD(s), which if you don’t have shared storage, will be the Local Storage of the Home Server, then click Import >
-
Select final networking settings and finalize the import. The VM should start automatically after the import is complete.
-
If you wish to have the VM start automatically when the Hypervisor/Host boots, you’ll need to ensure you re-enable the autostart option, as it does not get restored when importing a VM from a file. For that, you’ll need the to login to the shell (SSH/terminal) of one of the Xen Hosts, and will need the uuid of the VM (
xe vm-list
can help you there) and then from the shell, you need to execute:xe vm-param-set uuid=<UUID-OF-VM> other-config:auto_poweron=true