Q. How can I take a Volume Shadow Copy Service (VSS) backup of a volume and copy content from the shadow?

John Savill

November 4, 2008

1 Min Read
ITPro Today logo in a gray background | ITPro Today

A. 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.

About the Author

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like