A hot topic with any virtualization platform is virtual machine backup. Besides the traditional backup with a backup agent in the guest you can also backup the complete virtual machine as it sits on the file system on the virtualization host (in this case Windows Server 2008). Naturally, you will not want to shutdown your virtual machines just to take a backup so Hyper-V supports hot backups of running virtual machines with the Hyper-V VSS Writer.

Let's first see if the Hyper-V VSS Writer is available on the host. Issue the following command:

vssadmin list writers 

image

In some instances, the Hyper-V VSS writer is not listed even though Hyper-V is installed on the host. This could be due to broken symbolic links in the following directory: C:\ProgramData\Microsoft\Windows\Hyper-V\Virtual Machines. Remove the broken link files and issue the vssadmin list writers command again.

We will now perform a manual backup with the help of the Windows Server 2008 diskshadow.exe command. Open a command prompt and issue the diskshadow command. You will get a prompt inside diskshadow. Issue the following commands:

set context persistent

add volume <driveletter> alias <alias_you_choose>
(for example add volume s: alias svolume)

set verbose on

create

When you enter the create command, the VSS operation will create a new shadow copy. In the output you should see something like:

image

At the end of the output, you should see:

image

You can now enter the following command in diskshadow:

expose %alias% x:
(for example expose %svolume% x:)

The last command mounts the shadow copy on drive x: so that you have access to the backup. If you look at the contents of drive x:, it will be the contents of the volume you specified at the time the backup was taken. You can now copy the files from drive x: to some other location.

Note that the Hyper-V VSS writer will take care of the consistency of the virtual machines both outside and inside the vhd file. As long as you are using the integration components in the virtual machine (as you should), the virtual machine will stay running during the operation. If the volume contains virtual machines that do not have integration components, these virtual machines will be suspended to disk before the shadow copy is made and resumed afterwards. In that case, the shadow copy will contain the .bin and .vsv file with the state of the virtual machine at the time of the backup.

Inside the virtual machine that has the integration components you will see events in event viewer that indicate VSS activity:

image

A couple of notes on this process:

  • You can use add volume multiple times for different volumes. Naturally, for each volume a shadow copy will be created.
  • If you turn off the backup support of the integration components (can be done from Hyper-V manager or SCVMM 2008), the writer will suspend/resume the virtual machine.
  • You can integrate the Hyper-V VSS Writer with Windows Server 2008 Backup. See http://technet.microsoft.com/en-us/magazine/cc895627.aspx for more information. By default, Windows Server Backup is not configured to use the Hyper-V VSS Writer.
  • Backup software vendors are working to include support for the Hyper-V VSS Writer. BackupExec for instance should have support in version 12.5.

A following post will discuss how to restore a virtual machine from the backup location.