How to export and import VMs from Hyper-V

Microsoft Hyper-V is virtualization software that allows virtual machines to be created by virtualizing the OS and all hardware components. The ability to move virtual machines from one location to another without downtime is one of the main benefits of virtualization. Hyper-V also provides such mechanisms and one of them is, Export and Import functionality.

Export makes it easy to copy and transfer a VM to another location and import lets you restore it on any Hyper-V host. If you don’t have any backup solution in place, and in cases like complete hardware failure, you can use the exported VM files and restore the VM by performing the import.

In this article, we’ll look into the steps to perform Export and Import of a Hyper-V virtual machine using Hyper-V Manager and Powershell.

Hyper-V Export

Hyper-V Export is the process of exporting a complete Hyper-V virtual machine which includes the virtual hard disk files, VM configuration files, and Hyper-V snapshots a single component. This export can be performed either the VM is online or offline.

Prior to Windows 2012 export can be performed only when the Hyper-V virtual machines are offline. Also, you can’t export the VM directly to a network share, first you need to export to local storage and then you need to copy to share. Windows Server 2012 onwards both operations can be performed.

Use Cases of Hyper-V Export

  • Hyper-V Export can be used for archiving the virtual machines.
  • Hyper-V Export can be used in a test environment or any troubleshooting purposes.
  • Hyper-V export can be used as a backup if there is no backup solution available.

The export process of Hyper-V VM is often compared to Hyper-V snapshots and backups. Exporting VMs doesn’t go as fast as taking snapshots, but it allows us to create a complete copy of the VM and store it on another location, unlike Hyper-V snapshots.

The Hyper-V Export can not be considered as a full VM backup at the same time. It does not use compression, deduplication, and encryption methods, which are commonly used by data protection systems to minimize storage space and to more effectively use available disk space.

Hyper-V Import

Hyper-V Import is the process of recovering the exported virtual machine with all configuration. You can import the virtual machine to the source Hyper-V host or another one and the virtual machine will get registered with Hyper-V host. The Import Virtual Machine wizard also helps you fix incompatibilities that can exist when moving from one host to another.

Hyper-V import can be performed in three ways:

  • Register the Virtual Machine in-place
  • Restore the Virtual Machine
  • Copy the Virtual Machine

Register the Virtual Machine in-place

In this type of import, the source files in the location where you store run the VMs are not changed or moved in any way. And the Virtual machine’s unique ID remains the same as at the time of export.

Due to this, the VM is already registered with the Hyper-V host and if you attempt to import the VM without deleting the source VM with the ID, the operation will fail.

Hence, you need to delete the source to avoid duplicate ID occurrence and for a successful import.

When the import operation is complete, the export files become the running state files and can’t be removed.

Restore the virtual machine

Using this type, you can restore the virtual machine to a location you choose, or the default location configured with Hyper-V.

This import type will create a copy of the exported files and moves them to the selected location and once it’s imported, the virtual machine has the same ID as the time of export.

Because of this, if the virtual machine is already running in Hyper-V, you must delete that before the import starts.

And once the import completed the exported files remain intact and can be removed or imported again.

Copy the virtual machine

This import type is similar to the Restore type in that you select a location for the files. The only difference is that the imported virtual machine will have a new unique ID and it will help you to import the virtual machine to the same host multiple times.

Read More