Creating Snapshot of same Volume/Drive Multiple Times Using VSHADOW/DISKSHADOW
June 26, 2011 Leave a comment
Introduction:
In this blog am going to demonstrate how to create multiple snapshots of same volume/Disk/Drive in Windows environment using VSHADOW/DISKSHADOW.
How to Do this?
In order to perform multiple snapshot operations it is must to have VSS tool’s like VSHADOW(in Windows 2003 R2, SP2 and Windows 2008 Standard except Windows 2008 R2) or DISKSHADOW( only Windows 2008 R2).
So we have to write a DOS batch script or DOS command script to accomplish the multiple snapshot creation. Here am going to demonstarte how we can do it using the DOS script. Construct a DOS for loop based on number of times we want to take shadowCopy(Snapshot). Like
FOR /L %%A IN (0 1 32) DO echo “Something”
here something will be printed in Console 32 times.
Using VSHADOW
Find the following DOS batch script to execute it multiple times, just copy the following lines into a BAT file. Example ( ShadowCopy32.BAT)
@echo OFF FOR /L %%A IN (1 1 32) DO VSHADOW -p -nw E:
Here we are trying to take Snapshot/ShadowCopy for E drive.
-p Persistent snapshot/ShadowCopy
-nw – No Writer option.
How to do in Windows 2008 R2( using DISKSHADOW):
In windows 2008 R2 we can do it using DISKSHADOW when we are using diskshadow we can only insert script. So for this we need a Two BAT files usually one for running the for loop and another one will be set of commands DISHSHADOW has to execute. But am going to demonstrate how to do this using only one BAT file but purly using DOS commands.
Copy and paste the following lines into a BAT file example( ShadowCpy32.BAT) and run it.
@echo OFF echo set context persistent >> ExecuteScript.cmd echo add volume E: >> ExecuteScript.cmd echo create >> ExecuteScript.cmd echo reset >> ExecuteScript.cmd FOR /L %%A IN (1 1 32) DO diskshadow /s ExecuteScript.cmd del ExecuteScript.cmd
Set Context Persistent – Setting the context as persistent
Add Volume E: – Adding the base volume E: to take Snapshot/Shadow Copy
Create – Starts the ShadowCopy process
reset – Between every successive ShadowCopy process a reset is must.
Here we are creating a ExecuteScript.cmd file dynamically and this will be executed by DISKSHADOW 32 time once if it is completed we can delete the file.
Conclusion:
Feel free to comment and conduct if you have any queries.