Windows 2008 diskshadow utility and shadow copy

You can use diskshadow.exe, a new utility in Windows Server 2008, to create shadow copies and restore content from a shadow copy. Diskshadow.exe can create VSS snapshots, mount snapshots with a volume letter, and delete snapshots. The following script, written in the Diskshadow utility’s scripting syntax, creates a snapshot of the D drive, mounts the snapshot as drive X, calls a command file to copy files from X to a backup location, then unmounts the snapshot and deletes it.

#vmbackups.dsh

#Make shadows persistent

SET CONTEXT PERSISTENT

SET VERBOSE ON

#Cab location for process

SET METADATA d:tempBackup.cab

BEGIN BACKUP

#Alias volume with alias

ADD VOLUME D: ALIAS DVOL

#Create Snapshot

CREATE

#Expose the volume and run command file then unexpose

EXPOSE %DVOL% X:

EXEC D:Scriptscopycommands.cmd

UNEXPOSE X:

END BACKUP

#Delete the shadow copy

DELETE SHADOWS SET %VSS_SHADOW_SET%

 

The command file copycommands.cmd can contain any commands you need for copying your desired files from the shadow copy.

Save the script as vmbackups.dsh and run it using the command

diskshadow -s vmbackups.dsh

For more about Diskshadow scripts, see Microsoft’s page on the Diskshadow utility.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.