Announcement

Collapse
No announcement yet.

exchange server backup using vbs

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • exchange server backup using vbs

    Hi all. I need to backup my exchange server using vbscript and store the backup in my remote snap server and also whenever the backup fails its should send a email to all domain administrators. Currently I am using the below script which is written by senior admin.From this script how will I know what type of backup is run.

    exchange backup script

    ' VBScript source code
    Dim ntbReturn
    dim rsmEjectRetrun
    dim rsmPMRetrun
    Dim strRun
    Dim Msg
    Dim LogFile
    Dim LogRead
    Dim LogRet
    Dim NewLine
    Dim strStr
    Dim Counter
    Dim RepStr
    Dim BackUpDir
    Dim BackUpSet
    Dim DayOfWeek
    Dim strRSM
    Dim TapeSetFile
    Dim TapeSet
    Dim TapeRead
    Dim TapeToUse
    Dim strMon, strTue, strWed, strThu, strFri, sDate, sToday
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set WshShell = WScript.CreateObject("WScript.Shell")
    Set Msg = CreateObject("CDO.Message")


    DayOfWeek = FormatDateTime(Date,vbLongDate)
    DayOfWeek = UCase(Mid(DayOfWeek,1,3))

    'Define backup commands for each day.
    LogFile = "backup01.log"
    LogDir = "C:\BackupScripts\"
    strMon = "%WINDIR%\system32\NTBACKUP.EXE backup " & """@C:\BackupScripts\ExMon.bks"" /n ""Media created 1/8/2007 at 4:03 PM"" /d ""Set created 1/8/2007 at 4:03 PM"" /v:no /r:no /rs:no /hcn /m normal /j ""Exchange Monday"" /l:s /f ""\\snap1\windata\backups\exchange\ExMon.bkf"" "
    strTue = "%WINDIR%\system32\NTBACKUP.EXE backup " & """@C:\BackupScripts\ExTues.bks"" /n ""Media created 1/9/2007 at 4:08 PM"" /d ""Set created 1/8/2007 at 4:03 PM"" /v:no /r:no /rs:no /hcn /m normal /j ""Exchange Tuesday"" /l:s /f ""\\snap1\windata\backups\exchange\ExTues.bkf" ""
    strWed = "%WINDIR%\system32\NTBACKUP.EXE backup " & """@C:\BackupScripts\ExWeds.bks"" /n ""Media created 1/10/2007 at 4:09 PM"" /d ""Set created 1/8/2007 at 4:03 PM"" /v:no /r:no /rs:no /hcn /m normal /j ""Exchange Wednesday"" /l:s /f ""\\snap1\windata\backups\exchange\ExWeds.bkf" ""
    strThu = "%WINDIR%\system32\NTBACKUP.EXE backup " & """@C:\BackupScripts\ExThurs.bks"" /n ""Media created 1/11/2007 at 4:10 PM"" /d ""Set created 1/8/2007 at 4:03 PM"" /v:no /r:no /rs:no /hcn /m normal /j ""Exchange Thursday"" /l:s /f ""\\snap1\windata\backups\exchange\ExThurs.bkf """
    strFri = "%WINDIR%\system32\NTBACKUP.EXE backup " & """@C:\BackupScripts\ExFri.bks"" /n ""Media created 1/12/2007 at 4:11 PM"" /d ""Set created 1/8/2007 at 4:03 PM"" /v:no /r:no /rs:no /hcn /m normal /j ""Exchange Friday"" /l:s /f ""\\snap1\windata\backups\exchange\ExFri.bkf"" "
    strSat = "%WINDIR%\system32\NTBACKUP.EXE backup " & """@C:\BackupScripts\ExSat.bks"" /n ""Media created 1/12/2007 at 4:11 PM"" /d ""Set created 1/8/2007 at 4:03 PM"" /v:no /r:no /rs:no /hcn /m normal /j ""Exchange Friday"" /l:s /f ""\\snap1\windata\backups\exchange\ExSat.bkf"" "
    strSun = "%WINDIR%\system32\NTBACKUP.EXE backup " & """@C:\BackupScripts\ExSun.bks"" /n ""Media created 1/12/2007 at 4:11 PM"" /d ""Set created 1/8/2007 at 4:03 PM"" /v:no /r:no /rs:no /hcn /m normal /j ""Exchange Friday"" /l:s /f ""\\snap1\windata\backups\exchange\ExSun.bkf"" "
    'Determine Day and assign correct netbackup command.
    sDate = Date
    sToday = weekday (Date)
    Select Case sToday
    Case 1 ' Sunday
    strRun = strSun
    Case 2 ' Monday
    strRun = strMon
    Case 3 ' Tuesday
    strRun = strTue
    Case 4 ' Wednesday
    strRun = strWed
    Case 5 ' Thursday
    strRun = strThu
    Case 6 ' Friday
    strRun = strFri
    Case 7 ' Saturday
    strRun = strSat

    End Select

    'wscript.echo strRun

    ntbReturn = WshShell.Run(strRun,0,True)
    'ntbReturn = "0"

    Msg.To = "[email protected]"
    Msg.From = "[email protected]"
    '
    set LogRead = FSO.GetFile(LogDir & LogFile)
    set LogRet = LogRead.OpenAsTextStream

    LogRet.Skip(2)

    Do While Not LogRet.AtEndOfStream
    Counter = Counter + 1
    StrStr = StrStr & LogRet.ReadLine
    loop

    LogRet.Close

    RepStr = Replace(StrStr,Chr(0),"")

    if ntbReturn <> 0 then
    Msg.Subject = "Error running NT Backup on exchange-blr-04"
    Msg.textbody = ntbReturn & vbCRLF & vbCRLF & RepStr
    Else
    Msg.Subject = "Blr Exchange 2003 Backup"
    Msg.textbody = RepStr
    End if
    Msg.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
    Msg.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "tippy.cobaltgroup.com"
    Msg.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
    Msg.Configuration.Fields.Update
    Msg.Send


    'Wscript.Echo ntbReturn

    set WshShell = Nothing
    set fso = nothing
    set Msg = Nothing
Working...
X