Overview
There is a feature hidden away in Hyper-V, the Hyper-V VSS writer. With it, you can have Windows Server Backup grab your Hyper-V “application” state in the backups it makes. The Hyper-V VSS writer even goes into the guest OS and notifies it of the immanent VSS backup. This causes programs in the guest system with VSS writers (such as SQL or Exchange) to prepare themselves for backup, and when they finish, they notify the guest OS VSS service, which notifies the Hyper-V VSS writer that it is ready for backup. It really is a rather convenient method of backup, you can backup your critical systems on the fly with no need for downtime.
Note that you
must use a fixed size VHD for the Hyper-V VSS writer to work. Dynamic VHDs get silently ignored during the backup process. Additionally, fixed disk VMs without Hyper-V Integration components installed (or running an OS without VSS support) will be put into a save state while backing up without any warning. This means that if you have any absolutely critical services, you need them to reside in a fixed size VHD, running a VSS compatible OS with full integration components installed in order to have them backed up and avoid downtime during the backup process. This chart shows the outcomes of various combinations of OS support and VHD type:
Result of Windows Server Backup on currently running Hyper-V VMs | | Supported* OS | Unsupported* OS |
| Fixed Size VHD | Live backup, zero downtime | Put in save state, then backed up |
| Dynamic VHD | Not backed up at all | Not backed up at all |
*Supported, in this case, means a VSS enabled OS (newer than Windows XP) with Hyper-V
Integration components installed.
Implementation
Here are the quick steps to set up live backups of Hyper-V VMs:
- First, install Windows Server Backup by adding the feature in Server Manager.
- Next, add the Hyper-V VSS writer to Windows Server Backup. Unfortunately there isn’t a UI option for enabling this feature, so you need to do it manually by editing the registry. The easiest way is to paste this into a new file saved as VSSHyper-V.reg and then merge this file with your registry:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\WindowsServerBackup]
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\WindowsServerBackup\Application Support]
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\WindowsServerBackup\Application Support\{66841CD4-6DED-4F4B-8F17-FD23F8DDC3DE}]
"Application Identifier"="Hyper-V VSS Writer"
This will add the Hyper-V VSS Writer (represented by the GUID starting with 6684…) to Windows Server Backup. - Next, you need to enable shadow copy on volumes that have any part of the Hyper-V machine on them. You can do this by right-clicking the C drive in Explorer and clicking Configure Shadow Copies…
- Now you can run Windows Server Backup, create a new backup (be sure to select all drives that contain any piece of the Hyper-V machine, as well as check out the different VSS options in the Advanced Settings) and it will back up the Hyper-V machines as well.
- When you restore from the backup, if you select Application restore and Hyper-V as the application, it will restore all of the running VMs that were backed up (the non-running VMs were backed up as simple files in the WSB process) you cannot choose which VMs to restore. Additionally, the restore process lists the VMs simply as GUIDs, so you can’t even tell which ones are being restored.