Hello,
Finally I managed to create an script so the operator can schedule our
history backups (i.e. the backups that we must do 2 times a year, in
february and july, and maintain the data for almost 1 year).
The script that launch the operator is the following:
@ECHO OFF
cscript e:\historicos\historicos_schedule.vbs
schtasks.exe /query /fo table
The VBS script then calculates the actual date and schedules the savegrp for
the next sunday. The savegrp parameters por retention/browse are calculated
too in the VBS script so the data is retained for 1 year (in fact, for 1
year + 4 months until the month of the next history backup).
The VBS is like this:
'***********************************************
' Historicos_Schedule.vbs
'***********************************************
Dim sCommand
Dim WshShell
dim Fso
dim oStream
dim soutputfile
Set WshShell = WScript.CreateObject("WScript.Shell")
Set Fso = Wscript.createobject("Scripting.FileSystemObject")
soutputfile = "e:\historicos\historicos_savegrp.bat"
Wscript.Echo "======================="
Wscript.Echo "Historicos_Schedule 1.0"
Wscript.Echo "======================="
Wscript.Echo ""
D = Date '' Fecha Actual
Wscript.Echo "Fecha actual : " & D & " (" & WeekDayName(Weekday(D)) & ")"
' Calculo la fecha del siguiente domingo
E = D + 7 - (D+6) mod 7
Wscript.Echo "Fecha backup : " & E & " (" & WeekDayName(Weekday(E)) & ")"
' Calculo del mes actual
M = Month(D)
' Calculo de fecha caducidad
Select Case M
Case 7
FC = DateSerial(Year(D)+2,2,1)
WScript.Echo "Fecha caducidad : " & FC
Case 2
FC = DateSerial(Year(D)+1,2,1)
WScript.Echo "Fecha caducidad : " & FC
Case Else
WScript.Echo "Fecha caducidad : n/d"
WScript.Echo ""
WScript.Echo ">> Error : Hay que lanzar este script en febrero o
julio !"
WScript.Quit
End Select
' Creacion savegroup.bat
WScript.Echo ""
WScript.Echo "Creando/Modificando historicos.bat_savegrp ..."
Set oStream = fso.CreateTextFile(soutputfile, True)
oStream.Writeline "@ECHO OFF"
ostream.writeline "savegrp -l full -w """ & FC & """ -y """ & FC & """ -G
""LCFIB-Historicos"""
' Construccion del comando a ejecutar
WScript.Echo "Programando historicos_savegrp.bat ..."
sCommand = "schtasks.exe /create /sc once /ru system /tr " & soutputfile & "
/tn ""Historicos " & Right("0" & Day(E), 2) & "-" & Right("0" & Month(E), 2)
& "-" & Year(E) & """ /sd " & E & " /st 00:30:00"
intreturn = WshShell.Run(sCommand,0,True)
'sCommand = "schtasks.exe /query /fo table"
'WshShell.Run(sCommand,0,true)
oStream.Close
Set wshShell = Nothing
Set fso = Nothing
Set oStream = Nothing
WScript.Quit
After calculating the correct date, the VBS script generates a BAT file with
the correct parameters of savegrp and schedules it using 'schtasks' (from
Resource Kit) for the next sunday.
Thank you to everybody who helps me.
See you.
--
o o o Manel Rodero | LCFIB - UPC
o o o Systems Manager | Campus Nord - Modul B6
o o o Laboratori de Calcul | Jordi Girona, 1-3
U P C Facultat Informatica Barcelona | 08034 Barcelona (Spain)
|
manel AT fib.upc DOT edu | Tel: +00 34 93 401 6940
http://www.fib.upc.edu/~manel | Fax: +00 34 93 401 7040
To sign off this list, send email to listserv AT listserv.temple DOT edu and
type "signoff networker" in the
body of the email. Please write to networker-request AT listserv.temple DOT edu
if you have any problems
wit this list. You can access the archives at
http://listserv.temple.edu/archives/networker.html or
via RSS at http://listserv.temple.edu/cgi-bin/wa?RSS&L=NETWORKER
|