{"id":1207,"date":"2021-02-19T14:05:03","date_gmt":"2021-02-19T19:05:03","guid":{"rendered":"http:\/\/xfloyd.net\/blog\/?p=1207"},"modified":"2021-02-19T14:30:57","modified_gmt":"2021-02-19T19:30:57","slug":"xenserver-7-3-restore-vm-with-cli","status":"publish","type":"post","link":"http:\/\/xfloyd.net\/blog\/?p=1207","title":{"rendered":"XenServer 7.3 Restore VM with CLI"},"content":{"rendered":"\n<p><em>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.<\/em><\/p>\n\n\n\n<ol>\n<li>\n<p>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:<\/p>\n<pre><code>mount -t nfs 10.1.1.250:\/mnt\/backups\/xenbackups \/mnt\/backup\n<\/code><\/pre>\n<\/li>\n<li>\n<p>Take note of the filename &#038; path that you will use for restoration\/import, such as:<\/p>\n<pre><code>\/mnt\/backup\/Test-VM-2016-02-17_12-23-01.xva\n<\/code><\/pre>\n<\/li>\n<li>\n<p>If you don\u2019t 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:<\/p>\n<pre><code>xe sr-list\n<\/code><\/pre>\n<p>which will produce output such as this:<\/p>\n<pre><code>            uuid ( RO): 73a394e5-2a60-a13d-9c42-4987d81c1a77\n      name-label ( RW): DVD drives\nname-description ( RW): Physical DVD drives\n            host ( RO): XEN-SRV-4\n            type ( RO): udev\n    content-type ( RO): iso\n\n            uuid ( RO): 3b3346b2-d08a-90a8-bc13-321e0fe988d9\n      name-label ( RW): Removable storage\nname-description ( RW): \n            host ( RO): XEN-SRV-4\n            type ( RO): udev\n    content-type ( RO): disk\n\n            uuid ( RO): 69659292-ca18-3875-8c3b-1c9873db1dc0\n      name-label ( RW): Local storage\nname-description ( RW): \n            host ( RO): XEN-SRV-4\n            type ( RO): lvm\n    content-type ( RO): user\n<\/code><\/pre>\n<p>Take note of the uuid of the \u201c<code>Local Storage<\/code>\u201d of the host on which you wish to place the VM. In this case, if we want to place the VM on \u201c<code>XEN-SRV-4<\/code>,\u201d then we will need the uuid \u201c<code>69659292-ca18-3875-8c3b-1c9873db1dc0<\/code>\u201c<\/p>\n<\/li>\n<li>\n<p>Using the uuid &#038; 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:<\/p>\n<pre><code>xe vm-import filename=\/mnt\/backup\/Test-VM-2016-02-17_12-23-01.xva sr-uuid=69659292-ca18-3875-8c3b-1c9873db1dc0\n<\/code><\/pre>\n<p>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 <code>preserve=true<\/code> option such as:<\/p>\n<pre><code>xe vm-import filename=\/mnt\/backup\/Test-VM-2016-02-17_12-23-01.xva sr-uuid=69659292-ca18-3875-8c3b-1c9873db1dc0 preserve=true\n<\/code><\/pre>\n<\/li>\n<li>\n<p>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\u2019ll need the uuid of the VM (<code>xe vm-list<\/code> can help you there) and then you need to execute:<\/p>\n<pre><code>xe vm-param-set uuid=<UUID-OF-VM> other-config:auto_poweron=true\n<\/code><\/pre>\n<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>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. 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 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[28],"tags":[],"_links":{"self":[{"href":"http:\/\/xfloyd.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1207"}],"collection":[{"href":"http:\/\/xfloyd.net\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/xfloyd.net\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/xfloyd.net\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/xfloyd.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1207"}],"version-history":[{"count":6,"href":"http:\/\/xfloyd.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1207\/revisions"}],"predecessor-version":[{"id":1215,"href":"http:\/\/xfloyd.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1207\/revisions\/1215"}],"wp:attachment":[{"href":"http:\/\/xfloyd.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1207"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/xfloyd.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1207"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/xfloyd.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1207"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}