Did you know about DiskShadow? Creating Shadow Copy from the command line

This can be an alternative for taking a Snapshot in Hyper-V..
According to TechNet @Microsoft they state: DiskShadow.exe is a tool that exposes the functionality offered by the Volume Shadow Copy Service (VSS). By default, DiskShadow uses an interactive command interpreter similar to that of DiskRAID or DiskPart. DiskShadow also includes a scriptable mode.
Logo_windows-server-2008-hyper-v-logo-v_2

Note: DiskShadow.exe is not supported on Windows Server 2003 / Windows Vista!

Here are the commands for diskshadow to back up the VHD using VSS (its kicks off vss inside the VM so the data is consistent)

Go to cmd prompt:

diskshadow.exe
set context persistent
add volume d: alias ddrive
set verbose on
create
expose %ddrive% y:

This will take a VSS snapshop of my D drive (where my vhd lives) and then mounts it as drive letter Y: Now copy the contents of Y: to a safe place. When your done you can delete the snapshop and unmount Y:
Delete Shadows Volume D:

unexpose y:

 

The following sequence generates a shadow copy on volume D: that remains even after the end of the program but not on the file system as "previous version" is available. Theoretically, you could run this script periodically.

set context persistent
begin backup
add volume e:
create
end backup

DiskShadow_Create_Backup_Shadow

The Fact that shadow copies for this volume are in use can also be seen in explorer. Right-click the drive D: and go to Shadow Copies

DiskShadow_ShowShadowsExplorerDriveProperties

 

To list the shadow just use

List Shadows

and to expose a specific shadow

expose {ShadowCopyId} V:

don’t forget to discard / unexpose the drive when done!

unexpose V:

Links

DiskShadow Documentation @Microsoft Technet

One thought on “Did you know about DiskShadow? Creating Shadow Copy from the command line

  1. Any chance that this can be extracted from a Windows Server PC and applied to a Windows 7 machine?

    Tried copying diskshadow.exe and vsstrace.dll and it crashes at the “create” stage on Windows 7 Ultimate x86-64.

Leave a Reply

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