The ability to create a snapshot of a running VM and revert it back to the previous point can save administrators hours and minimize downtime. The basics of how Hyper-V snapshots work hasn't changed much since Microsoft introduced the feature in 2008 -- until now.
Windows Server 2012 introduces important changes that make Hyper-V snapshots more competitive with VMware's snapshot feature.
Best practices for Microsoft Hyper-V snapshots
Hyper-V snapshots aren't a comprehensive backup option; they are useful for problems that arise from software patches or configuration changes. Remembering to take a snapshot and training application personnel to request a snapshot before making any changes are critical.
Because snapshots use an .AVHD/.AVHDX file that increases in size as it tracks changes, it is important to remove snapshots as soon as you can after the application has been retested. As the size of a snapshot grows, it takes up more physical volume space. When it's time to delete older snapshots, merging larger files can slow VM performance.
Taking a Hyper-V snapshot of a live VM
Taking a Hyper-V snapshot within Windows Server 2012 is simple. Open Hyper-V Manager and right-click on the VM you want to take a snapshot of and choose Snapshot.
You can see the progress of the snapshot in the status column of Hyper-V Manager. The time it takes for the snapshot to process is based on the overall I/O that's available to the VM, as well as the IOPS the virtual machine's disk is processing at the time of the snapshot. When the snapshot is complete, you will see a notification in the Snapshots pane.
Removing and deleting Hyper-V snapshots
To merge a snapshot with previous versions of Hyper-V, you need to shut down the VM, delete the snapshot, and then wait until the .AVDH file-merge process is complete. This file can grow very large if you took the snapshot several days ago or if the VM is running a high-transaction application.
The merge process, which writes changes to the VM's main virtual disk, could take several minutes to a few hours. This process should occur while the application is shut down.
Because snapshots return a system to a previous version of the VM, they're a great bailout option. However, these merge operations often create downtime that could actually take longer than that of a bad patch or upgrade. Still, traditional snapshots have benefits if your timing is correct. Admins often need to schedule snapshot-merge operations during off-peak hours -- late in the day or early in the morning to avoid service interruptions. Hyper-V 3.0 in Windows Server 2012 overcomes this issue by switching to the parent file while the VM is running.
Hyper-V administrators have asked for the new ability to live-merge snapshots into running VMs. This capability brings Hyper-V's snapshot feature up to par with VMware snapshots. However, both Hyper-V and VMware suffer from potential disk I/O reductions during the merge process if the VM workload is also under moderate I/O stress during the process. This is why it's extremely important to know your VM workloads and their peak I/O times before running a live-merge snapshot.
The new Hyper-V snapshot features can eliminate the need for after-hours work and reduce downtime, but it's important to get application teams on board with requesting snapshots prior to upgrading or performing critical configuration changes to VMs. The next step may be giving your applications teams free rein to manage their own creation and deletion of snapshots through a self-service portal. This process, however, requires tight monitoring of available disk space to avoid disrupting other VMs on the same LUN.
The process of removing and deleting snapshots within Hyper-V in Windows Server 2012 includes the following steps:
- Open Hyper-V Manager.
- Select the virtual machine.
- In the lower Snapshots pane, right-click the snapshot you would like to remove and choose Delete Snapshot.
- You will see the progress of the snapshot deletion in the Status column followed by a "Merge in Process: Succeeded" message.
Hyper-V will store .AVHD/.AVHDX files in the same location as VHD/VHDX files. Hyper-V also creates a snapshots directory to store state information from the point in time when the snapshot was taken.
The default snapshot file location is the same as that of the VHD/VHDX files.
During the merge process, Hyper-V deletes the state information in the snapshots folder instead of merging it into the main VHD/VHDX file. The snapshots folder will remain, but it will be empty.