Updated: April 17, 2012
Applies To: Windows Server 2008, Windows Server 2012, Windows 8
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.
Membership in the local Administrators group, or equivalent, is the minimum required to run DiskShadow.
For examples of how to use DiskShadow commands, see Examples.
For interactive mode, type the following at the command prompt to start the DiskShadow command interpreter:
For script mode, type the following, where script.txt is a script file containing DiskShadow commands:
diskshadow -s script.txt
You can run the following commands in the DiskShadow command interpreter or through a script file:
Sets the context, options, verbose mode, and metadata file for creating shadow copies.
Tests writer involvement in restore sessions on the computer without issuing PreRestore or PostRestore events to writers.
Loads a metadata .cab file prior to importing a transportable shadow copy or loads the writer metadata in the case of a restore.
Verifies that a writer or component is included or excludes a writer or component from the backup or restore procedure.
Adds volumes to the set of volumes that are to be shadow copied, or adds aliases to the alias environment.
Starts the shadow copy creation process, using the current context and option settings.
Executes a file on the local computer.
Starts a full backup session.
Ends a full backup session and issues a BackupComplete event with the appropriate writer state, if needed.
Starts a restore session and issues a PreRestore event to involved writers.
Ends a restore session and issues a PostRestore event to involved writers.
Resets DiskShadow to the default state.
Lists writers, shadow copies, or currently registered shadow copy providers that are on the system.
Deletes shadow copies.
Imports a transportable shadow copy from a loaded metadata file into the system.
Removes hardware shadow copies that were imported by using the import command.
Exposes a persistent shadow copy as a drive letter, share, or mount point.
Unexposes a shadow copy that was exposed by using the expose command.
Disassociates a shadow copy volume from VSS.
Reverts a volume back to a specified shadow copy.
At a minimum, only add and create are necessary to create a shadow copy. However, this will forfeit the context and option settings, will be a copy backup, and will only create a shadow copy with no backup execution script.
This is a sample sequence of commands that will create a shadow copy for backup. It can be saved to file as script.dsh, and executed with DISKSHADOW /s script.dsh
Assume the following:
You have an existing directory called c:\diskshadowdata.
Your system volume is C: and your data volume is D:.
You have a backupscript.cmd file in c:\diskshadowdata.
Your backupscript.cmd file will perform the copy of shadow data p: and q: to your backup drive.
You can enter these commands manually or script them:
#DiskShadow script file set context persistent nowriters set metadata c:\diskshadowdata\example.cab set verbose on begin backup add volume c: alias SystemVolumeShadow add volume d: alias DataVolumeShadow create expose %SystemVolumeShadow% p: expose %DataVolumeShadow% q: exec c:\diskshadowdata\backupscript.cmd end backup #End of script