Invoking diskshadow to back up a Virtual Machine from a Hyper-V Host

DiskShadow.exe is a new tool that shipped with Windows Server 2008 and it allows you to create and restore shadow copies (snapshots).

The tool is similar to vshadow (a free tool that ships with the Volume Shadow Copy/VSS SDK), but it has a diskpart-like interface.

You can invoke DiskShadow from a cmdline, or you can pass a script to it using the command "diskshadow -s script.txt"

Below, i will show you an example script to back up all VMs of a Hyper-V Host. First, we need to know the ID of the VSS writer for Hyper-V. To do that you need to invoke the command "list writers" from diskshadow (or from vssadmin). Once you parse its content, look for this GUID as per below underlined text.

        * WRITER "Microsoft Hyper-V VSS Writer"
                - Writer ID   = {66841cd4-6ded-4f4b-8f17-fd23f8ddc3de}
                - Writer instance ID = {d49be452-e26e-4255-a723-bfb9f996e703}

Once you know the ID, you can use a script like one below to create a snapshot for the volume the VM resides on and ensure that the VSS writer for Hyper-V is included in the snapshot process.


# DiskShadow script file to backup a single VM from a Hyper-V host
set context persistent

# make sure the path already exists
set metadata c:\
set verbose on

begin backup
add volume d: alias SystemAndDataVolumeShadow

# verify the "Microsoft Hyper-V VSS Writer" writer will be included in the snapshot
writer verify {66841cd4-6ded-4f4b-8f17-fd23f8ddc3de}

end backup

As you run this, you will see that the Hyper-V VSS writer is included in the shadow copy process and is participating in the backup (other writers might be included too since I chose a writer-involved snapshot and those writers might have data on the volumes selected for backup). Once the snapshot is complete, you can mount the snapshot to a mount point (you can do this using the expose diskshadow command) and copy the entire configuration for the VM to a backup location. You can see which files comprise this VM by looking at the metadata created in the CAB file (look into manifest.xml to see which XML file corresponds for the Hyper-V writer and you can get the specific writer metadata there).

 good luck - backup is essential 🙂 (and don't forget that Data Protection Manager does backup like no other application and a lot more)

Comments (9)
  1. Anonymous says:

    Here’s my obscenely vast list of resources that I actually do reference and send to customers on a very

  2. I think you mean vssadmin and not diskpart

    e.g.: vssadmin list writers

  3. Anonymous says:

    (updated 9/26/08) My current project involves being the only dedicated technical resource on the Virtualization

  4. Michael Michael [Apprenda] says:

    hi there,

    you need to ensure that you are running the backup as an administrator and that the Hyper-V role has been enabled on Win2k8. Then the VSS writer for Hyper-V should show up.

  5. SteveJHU says:

    I got the same error as KarlMitschke above. When I removed the Writer Verify line, a Shadow Copy was created. However, when I restored a Virtual Machine from the Shadow Copy and started it, an error message was reported that it was shutdown unexpectedly. That’s what was fixed by VShadow.exe in Server 2003, and which the new Diskshadow utility with the Hyper-V VSS Writer is supposed to prevent.  And yes, Hyper-V is installed and running, and I am logged on as an admin. Any ideas anyone?

  6. Anonymous says:

    I have been able to get it to work, but the VSS Hyper-V writer isn’t listed.

    The backup seems to be going okay, I have yet to try restoring it to a different hyper-v server to bes ure.

    Do you have any more information about whether or not the VSS writer you mentioned must be included?

    Or is it possbile that in Hyper-V RTM, the seperate Hyper-V writer has been integrated into some system driver?

    I have also used VSSAdmin to list the writers, which give a much more compact overview, but it’s not listed there either.

    Any help would be greatly appreciated.

  7. OldKarlm says:

    When I try this, I get the following error:

    "The component "Microsoft Hyper-V VSS Writer" was not found in the writer components list. Aborting backup …

    Check the syntax of the component name."

  8. Anonymous says:

    My current project involves being the only dedicated technical resource on the Virtualization RDP Team.

Comments are closed.

Skip to main content