Adi Oltean [MSFT]
Guest
|
Posted:
Fri Mar 19, 2004 11:12 pm Post subject:
Re: Shadow Copy Scheduling |
|
|
Hi Brian,
You should be able to implement a more advanced shadow copy management if
you write some specialized BAT/CMD/VBS scripts that gets invoked
periodically. This script will selectively delete older shadow copies and
maintain the correct number of shadow copies that you need, according to
their creation date and time. Then, you can just create a Scheduled Task
using SCHTASKS.EXE command line (or the task scheduer UI) that periodically
cleans up snapshots at certain times, by invoking this script .
Also, of course you can also modify the scheduled task that creates the
shadow copies if the default schedule is not appropriate.
The script can selectively query & delete shadow copies using the WMI shadow
copy management classes (Win32_ShadowCopy, etc). Alternatively, you can just
use the VSSADMIN.EXE command. Please see the MSDN documentation for the
Win32_ShadowCopy class for more details, or check the help for VSSADMIN LIST
SHADOWS.
Here is a simple VBScript example which will delete all shadow copies that
are more than two weeks old, with the exception of those created Sunday:
Dim namespace
Set namespace = GetObject("winmgmts://localhost/root/cimv2")
Dim objSet
Set objSet = namespace.ExecQuery("select * from Win32_ShadowCopy")
Dim dateTime
set dateTime = CreateObject("WbemScripting.SWbemDateTime")
Dim vbDate
for each obj in objSet
dateTime.Value = obj.InstallDate
vbDate = dateTime.GetVarDate(True)
WScript.echo "- Snapshot on " & _
obj.VolumeName & " @ " & vbDate
if (DateDiff("d", vbDate, Date) > 14) then
dayOfWeek = DatePart("w", vbDate)
WScript.Echo "dayOfWeek = " & dayOfWeek
if (dayOfWeek <> 5) then
WScript.echo " [Deleting snapshot...]"
obj.Delete_()
end if
end if
next
In the end this script will achieve something similar with what you want -
keep daily shadow copies for the last two weeks, then keep only weekly
shadow copies for the rest. Of course, you can develop a more advanced
version of this script that will perform a more granular filtering, which
will selectively clean up shadow copies depending of their "age", similar
with what you have below.
Thanks, Adi
P.S. This posting is provided "AS IS" with no warranties, and confers no
rights. Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
"Brian" <burkebr4@pharma.com> wrote in message
news:OrugCoDDEHA.2628@TK2MSFTNGP11.phx.gbl...
| Quote: | I'm attempting to create a schedule to allow the following number and
types
of Shadow Copies of my volumes. Is there an easy way to do it?
Perform daily copies M-F at 10 am and 2 pm - keep 48 (24 days worth).
Perform weekly copies on Sunday and keep 16 (4 months worth)
When the 49th daily is attempted to be created it deletes the oldest
'daily'
NOT the oldest snapshot (which would be the weekly). When the 17th weekly
is
attempted to be create it deletes the oldest 'weekly'. This way I have
weeklies covering 4 months with dailies covering the last month. This is
what Netapp snapshot scheduling allowing and we are trying to mirror that
functionality.
Thanks
burkebr4@pharma.com
|
|
|