Announcement

Collapse
No announcement yet.

Send Ntbackup Logs Using Bmail!!help

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

  • Send Ntbackup Logs Using Bmail!!help

    hai all i am using windows 2003 ntbackup to backup ACTIVE DIRECTORY AND EXCHANGE SERVER.IS THERE ANY WAY TO SETUP NTBACKUP LOGS ONCE THE BACKUP IS OVER ON A DAILY BASIS.
    I HAVE INSTALLED A UTILIY CALLED BMAIL TO SEND THE BACKUP REPORT.BUT THE PROBLEM I FACED IS THE BATCH FILE WHICH I GOT IS HAVING SOME SYNATX PROBLEM.SO CAN ANYONE HELP ME TO CORRECT THIS BATCH FILE.


    @echo off

    :: Name this script

    SET _SCRIPTNAME=

    :: Define backup logfile parameters

    set _LOGLOCATION=

    set _Text2Mail=%systemdrive%\bmailtext.txt


    :: Define bmail parameters

    :: EXELOCATION is the location of the BMAIL executable.

    set _EXELOCATION=

    set _SMTPSERVER=

    set _TOADDR=

    set _FROMADDR=

    set _SUBJECT=”Backup Log for %_SCRIPTNAME%“


    :: Find most recent logfile

    :: Using the /od option of the DIR command lists the files in the order they were last modified, newest being on the bottom.

    :: The /b option removes any other formatting from the output of the DIR command.

    for /f %%j in (’dir “%_LOGLOCATION%\backup*.log” /od /b’) do set _currentLog=%%j


    :: Because of the formatting of the logfile, not all email programs render it properly.

    :: Therefore we output the contents of the logfile to a plain ASCII text file.

    type “%_LogLocation%\%_CurrentLog%” >> %_Text2Mail%


    :: Send our email using the ASCII text file generated above as the message body.

    %_EXELOCATION%\bmail -s %_SMTPSERVER% -t %_TOADDR% -f %_FROMADDR% -a %_SUBJECT% -m “%_Text2Mail%” -c


    :: Delete our text file

    del %_Text2Mail%


    BATCH FILE I CREATED

    @echo off
    SET _SCRIPTNAME=exch-bck-report
    set _LOGLOCATION=C:\Documents and Settings\sudheshpn\Local Settings\Application Data\Microsoft\Windows NT\NTBackup\data
    set _Text2Mail=%systemdrive%\bmailtext.txt
    set _EXELOCATION=c:\bmail
    set _SMTPSERVER=192.168.141.61
    set [email protected]
    set [email protected]
    set _SUBJECT=”Backup Log for %_SCRIPTNAME%“
    for /f %%j in (’dir “%_LOGLOCATION%\backup*.log” /od /b’) do set _currentLog=%backup08.logj
    type “%_LogLocation%\%_CurrentLog%” >> %_Text2Mail%
    %_EXELOCATION%\bmail -s %_SMTPSERVER% -t %_TOADDR% -f %_FROMADDR% -a %_SUBJECT% -m “%_Text2Mail%” -c
    del %_Text2Mail%

  • #2
    Re: Send Ntbackup Logs Using Bmail!!help


    In the batch you only have to add values at the lines starting with "Set", I think joseph m davis did a nice job there making his script easy to use.
    Why did you make these changes to this line ???:
    for /f %%j in (’dir “%_LOGLOCATION%\backup*.log” /od /b’) do set _currentLog=%backup08.logj

    Code:
    :: Created By Joe Davis
    :: http://josephmdavis.com/?p=35
    :: This script will email the latest backup logfile to a specified user or group.
    
    @echo off
    
    set _SCRIPTNAME=exch-bck-report
    
    set _LOGLOCATION=C:\Documents and Settings\sudheshpn\Local Settings\Application Data\Microsoft\Windows NT\NTBackup\data
    
    set _Text2Mail=%systemdrive%\bmailtext.txt
    
    set _EXELOCATION=c:\bmail
    
    set _SMTPSERVER=192.168.141.61
    
    set _TOADDR=[email protected]
    
    set _FROMADDR=[email protected]
    
    set _SUBJECT="Backup Log for %_SCRIPTNAME%"
    
    
    Title %_SCRIPTNAME%
    
    for /f "delims=" %%j in ('dir "%_LOGLOCATION%\backup*.log" /OD /B /A-D 2^>NUL') do SET "_currentLog=%%j"
    
    If Defined _currentLog (
       type "%_LogLocation%\%_CurrentLog%" >> "%_Text2Mail%"
       start ""/w "%_EXELOCATION%\bmail.exe" -s %_SMTPSERVER% -t %_TOADDR% -f %_FROMADDR% -a %_SUBJECT% -m "%_Text2Mail%" -c
       del "%_Text2Mail%"
    ) ELSE (echo.Unable to find any backuplog!)
    note
    In the original batch script (and in your script) there are “ and ” signs used - these can better be changed to a straight quote( " ) . Also all ‘ and ’ signs - need to be changed to a straight singlequote( ' ).


    sudheshpn when you paste a script, can you wrap it next time between a [code] ... [/code] -tag please, that will make the code better readable.


    \Rems

    FYI
    Utilities useful for creating scripts where mail has to be sent automatically:
    BMAIL.exe : http://www.beyondlogic.org/solutions...mdlinemail.htm
    BLAT.exe : http://www.blat.net/194/
    Last edited by Rems; 13th May 2008, 15:55.

    This posting is provided "AS IS" with no warranties, and confers no rights.

    __________________

    ** Remember to give credit where credit's due **
    and leave Reputation Points for meaningful posts

    Comment

    Working...
    X