Hyper-V or VHD Backup

One of the main advantages in virtualization is having the ability to quickly recover
failed systems. By turning a system into a virtual system you are actually turning
it into a file that can be used on any system that has Hyper-V installed on it thus
enabling quick recovery of a failed system.

The main problem is that to be able to backup a VHD file you need to stop the
virtual machine. Now obviously, on mission critical systems you can’t stop a system
every time you want to back it up. To overcome this issues, you can us the Volume
Shadow Service (VSS) mechanism to take a snapshot of the volume that stores
the VHD files and then copy the relevant files to external storage.

Taking a snapshot of a VHD file is possible since Windows 2008 has a built-in Hyper-V
VSS Writer that brings the virtual machine’s hard drive (the VHD file) to a consistent

Once the snapshot is taken, you can manually mount the snapshot and back it up.

To do this, you should use a tool included with Windows 2008 called ‘diskshadow.exe’.
Diskshadow is an interactive interface to VSS. It has a vast list of commands but if we
concentrate on our specific issue you need to issue the following commands:

set context persistent
[You can set it to volatile if you would like to have the snapshot deleted once you exit
the diskshadow.exe application]

add volume <driveletter> alias <alias_you_choose>
(for example add volume t: alias VHDBackup)

set verbose on


Once you complete this set of command you have a snapshot stored.You can view
the stored snapshots by executing the following command:

list shadows all

Once you are ready to back the VHD up, expose the snapshot you would like to use by
using the following command:

expose <ShadowID> <Drive:>

Now you can access the data as you would any drive on your system. To hide the snapshot
execute the following command:

unexpose t:


The major advantage of this feature is that you don’t need to stop a virtual machine
to back it up. From my experience the process of taking a snapshot is relatively quick
and it does not tax a system but I would advise that you do it during afterhours.
One more point to consider is disk space,monitor it closely and delete unused snapshots.

5 thoughts on “Hyper-V or VHD Backup

  1. I was able to perform diskshadow backup successfully to 2 servers except one. Their only difference is that the other server has a VPS that is still has unmerged snapshots.

    Should all the VPS finish the merging of snapshots before I can use diskshadow?

Leave a Reply

Your email address will not be published. Required fields are marked *