Freigeben über


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:\example.cab
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}
create

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

  • Anonymous
    January 01, 2003
    Here's my obscenely vast list of resources that I actually do reference and send to customers on a very

  • Anonymous
    January 01, 2003
    I think you mean vssadmin and not diskpart e.g.: vssadmin list writers

  • Anonymous
    January 01, 2003
    (updated 9/26/08) My current project involves being the only dedicated technical resource on the Virtualization

  • Anonymous
    January 01, 2003
    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.

  • Anonymous
    January 01, 2003
    The comment has been removed

  • Anonymous
    January 01, 2003
    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.

  • Anonymous
    January 01, 2003
    http://blogs.technet.com/m2/archive/2008/04/17/invoking-diskshadow-to-back-up-a-virtual-machine-from

  • Anonymous
    January 01, 2003
    The comment has been removed

  • Anonymous
    January 01, 2003
    My current project involves being the only dedicated technical resource on the Virtualization RDP Team.