Because Hyper-V runs as a role on Windows Server, it might stand to reason that backing up a Hyper-V host works in exactly the same way as backing up any other Windows Server. Although a Hyper-V host is at its core just a Windows server, Hyper-V servers require special consideration when it comes to backup and recovery.
Administrators must for example, determine whether it is better to perform backups at the host server level, or to perform backups from inside the individual virtual machines (a practice known as a guest backup). Host level backups are generally the preferred backup method, as these types of backups capture all of the virtual machines that are running on the host. In contrast, guest backups are effective for backing up a virtual machine’s contents, but require each VM to be backed up individually. Furthermore, guest backups capture only the virtual hard disk contents, rather than the virtual machine itself. This means that the virtual machine’s settings are not backed up, nor are its checkpoints.
Host level backups require the backup application to be Hyper-V aware, and are based on the Volume Shadow Copy Service. Although these backups are made at the host level, the Volume Shadow Copy Services (VSS) process each VM individually. The reason for this is that there are two different methods that are used to back up the virtual machines, depending on the VM’s capabilities. It is not uncommon for both methods to be used when backing up the VMs on a single host, with some VMs requiring one backup method, and other VMs using the other.
The first of these two backup methods is known as the saved state method. This is the less desirable of the two methods, but is sometimes necessary. Like the other backup method, this method is based around the use of VSS snapshots. The disadvantage to using this method however, is that the VM must momentarily be placed into a saved state while the VSS snapshot is created.
The other backup method (and the more preferable of the two) is called the Child VM Snapshot method. Rather than placing the VM into a saved state while the VSS snapshot is created, the backup application actually looks inside of the VM and runs VSS at the guest OS level.
Because child VM snapshots are the preferred method for protecting virtual machines, Hyper-V backup applications are usually designed to use this method whenever possible. It is ultimately up to the backup application to determine which method to use, and the backup operator is not usually involved in the selection process.
In order for a child VM snapshot to be taken, the VM must meet certain requirements. If those requirements are not met, then a saved state backup is taken instead. These requirements have evolved significantly over time, but the current requirements include:
- The Backup integration service must be enabled for the VM
- The VM must be in a running state
- The VM’s snapshot file location has to be set to the same the same volume in the host operating system as the VHD files for the VM
- All of the VM’s volumes have to reside on basic disks. Dynamic disks cannot be used within the VM
- The VM’s volumes must use a file system such as NTFS that supports the use of snapshots
The actual backup process is somewhat similar to any other VSS backup. The process begins with something that Microsoft refers to as a Prepare for Snapshot event. This is the phase of the backup process in which VSS either places the VM into a saved state or creates a child level snapshot.
When the Hyper-V VSS writer completes its shadow copy preparation, the writer informs VSS that it is ready for the shadow copy to be created. At this point, VSS instructs the provider to create a shadow copy. Because shadow copies are nothing more than snapshots, the creation process only takes a few seconds. Once the shadow copy has been created, VSS thaws the system, which puts any saved state VMs back into their previous state and resumes all normal I/O operations for all VMs.
Although Hyper-V has existed long enough for the backup process to mature, there is still sometimes a stigma associated with Hyper-V backups due to extreme limitations found in early backup solutions. The first versions of Windows Server backup to support Hyper-V for example, did not allow individual virtual machines to be restored. Today however, these limitations no longer exist. Modern Hyper-V backup products provide granular recovery capabilities that allow for the restoration of individual VMs, as well as files and applications running within a VM.