Did you know about DiskShadow? Creating Shadow Copy from the command line
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
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
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
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.