Live Exporting Windows Server 2012 R2 Hyper-V VMs
An export operation packages up a copy of a virtual machine so you can transport it to another Hyper-V host or cluster member and import the virtual machine. Performing that task in Windows Server 2012 R2 (WS2012 R2) is commonly referred to as “live exporting” of virtual machines. In this article, I will explain how WS2012 R2 improved how you can export virtual machines.
Exporting VMs Before Windows Server 2012 R2
Before WS2012 R2 was released, you always had to shut down or power down a virtual machine to do an export of a virtual machine. This isn’t great in a DevOps world, as it would be great to have actual copies of production systems that you can test without bringing down those production systems in the first place.
That would be kind of ironic because the idea of getting a copy of the virtual machine is to test manipulative operations and rollback actions to ensure that production systems are not damaged.
Hyper-V Virtual Machine Live Exporting
WS2012 R2 brought some new functionality that the community calls a live export. This package of features enables us to do two things:
- Export a running virtual machine: With this feature, a Hyper-V administrator can export a running virtual machine. This is an incredibly useful feature, as you can grab a copy of a production virtual machine, make a copy of the virtual machine, import it to a host, and perform tests on the virtual machine in an isolate test network. I think this should prove valuable in the remaining months before Windows Server 2003 support ends in July 2015.
- Export a checkpoint: Checkpoints, formerly known as snapshots, are commonly used in test and development labs. Each checkpoint contains a capture of a virtual machine from a previous point in time. Applying a snapshot causes a virtual machine to travel in time, changing the memory, processor, and disk contents to what they were at the time that the checkpoint was created. A Hyper-V administrator can export one of these snapshots, which creates a standalone export of a virtual machine that can be imported on the same host or another host, hopefully on an isolated network.
How to live export a running virtual machine or snapshot from WS2012 R2 Hyper-V. (Image: Aidan Finn)
Exporting a Virtual Machine
The process for exporting a virtual machine is pretty simple. Open Hyper-V Manager, right-click on the virtual machine, and select Export. A pop-up window called Export Virtual Machine will appear. Enter the path where you want the export to be saved. The export will start immediately after you click OK, whether the virtual machine is running or not.
In my example (see the previous screenshot), the virtual machine VM01 has multiple nested checkpoints. When I export the virtual machine to D:Exports a new subfolder is automatically created to store the export. This subfolder is named after the virtual machine (D:ExportsVM01). Once the export is complete, I can browse the folder and find a packaged version of my virtual machine in the new subfolder:
- D:ExportsVM01Virtual Machines: This contains the XML configuration file, and the VSV (save state) and BIN (save state placeholder) files for the virtual machine.
- D:ExportsVM01Virtual Hard Disks: The VHDX (virtual hard disks) and the AVHDX (checkpoint differencing hard disks) are found here.
- D:ExportsVM01Snapshots: The configuration files for each checkpoint are stored here. This includes a XML configuration file, a BIN file and a VSV file to save the state of the virtual machine from the time that the checkpoint was created.
In other words, the virtual machine and all of the dependent checkpoints are packaged up when you export a virtual machine.
I can also export a checkpoint. Make sure that there are no outstanding export operations on your virtual machine or its checkpoints, select a checkpoint, right-click the desired checkpoint, and select Export. The same Export Virtual Machine dialog will appear and the process will also create a subfolder named after the virtual machine. However, the export process works a little differently.
Instead of exporting an virtual machine with all of its dependent checkpoints, with this process a virtual machine without any checkpoints is created in the export subfolder from the original checkpoint. It appears that Hyper-V is using the metadata (XML, VSV, BIN) files to create the virtual machine, and performing a merge operating to create a new VHDX file without any AVHDX files (checkpoints). This gives you a nice clean export, but keep in mind that the merge operation might take a little time.
You can later import the virtual machine to the same host or another host. But remember: If this is a copy of a running virtual machine, then you really should place the imported virtual machine on an isolated network. This process is like using Ghost to clone a physical machine and then deploying that image to another computer. You do not want identical identities on the same network.