cancel
Showing results for 
Search instead for 
Did you mean: 

EZ Points for Scripters

Lance_Hoskins
Level 6
Ready, Set, GO!

Situation: I'm using NBU6.0 MP3 running on a W2K3 SP1 master and media servers. I have never used the notify scripts, but would like to play around with them. I'm trying to modify the backup_exit_notify script so that it will tell me when any of my Exchange backups get a status that's not 0 or 150.

Problems:
1) How's this code look to all of you windows batch scriptors out there?

@if %2 EQU "PolicyName" && %5 GTR 0 && %5 NEQ 150 goto :ExchangeFailed
:ExchangeFailed
@blat -body "Exchange Backup Failure" -subject "The Exchange Backup for %1 failed." -t me@work.com -f NetBackup@work.com -server mail.work.com

2) How come when I modify this cmd file from within Notepad it takes away the formatting of the file, causing it to fail the next time it's called (specifically takes away the character returns so that everything in the file is one long string.

HELP!

Lance
21 REPLIES 21

DavidParker
Level 6
2. Because Notepad is teh ghey! I would suggest using Wordpad instead. Or download a real text editor from the Net (EditPad Pro?).

Lance_Hoskins
Level 6
Thanks for the lead David. I have Notepadd++ and it seems to do the same thing. I've set the type to Unix and still get the same result. Help a Windows brother out! :)

DavidParker
Level 6
Give Wordpad a try?
I think that one plays better with 's ...

Lance_Hoskins
Level 6
Wordpad won't even open the original nicely. It opens without any CR's...

DavidParker
Level 6
Dang!
That's harsh!

I only have vicarious knowledge of a few other editors ... =(
Maybe some of the *nix guys can point you towards a better editor ...
Anyone?

Lance_Hoskins
Level 6
That and some correct syntax. Like I said, I want it to have an "if" statement that checks for policy name, then a status of greater than 0 but not 150. If someone can show me the syntax for that piece of it that'd help too. I have tried a couple of things, but it doesn't like them (<>).

Ugh, I think I'm heading home now. Too much fun for one day!

Dennis_Strom
Level 6
try installing cigwyn and then using vi.
I have no knowledge of wordpat or notepad. If you can use awk or grep or other UNIX like commands I might be able to help out.

Chia_Tan_Beng
Level 6
> Wordpad won't even open the original nicely. It
> opens without any CR's...

On notepad, have you check the "Word Wrap" under format menu?

On WordPad, you can turn on the "Word Wrap" from View -> Options, under the tabs of Text, Rich Text, etc, you can check the Word Wrap option.

Nathan_Kippen
Level 6
Certified
Textpad is another one that I've used. It's good for a lot of things.

zippy
Level 6
VI editor allways works!

Hail to BILLY SERVERS! I bow to you Billy G..

I'm just glad my Veritas Master is on UNIX.

JD

Lance_Hoskins
Level 6
Thanks JD, VI will likely become my friend from here on out. I give you 5 for that. If you can give me some good links or examples of the syntax you use (for operands such as equals, not equals, etc. as well as for mailing functions if applicable) it's worth another 10 to ya! :)

With regards to your Billy servers comments, in the words of our good friend Donald Duck, "Shuddup!" ;)

Lance_Hoskins
Level 6
Quick update as to what I'm trying to accomplish.

As some of you may already know, when an Exchange backup fails, it fails with a status 1. While I'm sure to some of you a status 1 is unheard of in your environment (**cough**Bob**cough**), but we have plenty of clients that finish with a status 1 for a number of reasons. So, that being said, we were going to try doing cumulative backups every other day on Exchange and let the logs grow for 2 days rather than 1, but if we had any failure in the full job and the logs didn't flush, we'd hit a limit on the number of logs that Exchange could handle.

Bottom Line
I want to know when an Exchange backup finishes with anything but a status 0 or 150. I thought I could do somehing like the following to the backup_exit_notify.cmd, but it doesn't seem to be working. Any ideas?

@if "%2" != "P-Exchange-Stores" goto NotExchange
:NotExchange
@if "%5" > 0 && != 150
@blat SendE-Mail

Thoughts? I know the && doesn't work, but the != doesn't seem to work either. HELP!

Lance

Dennis_Strom
Level 6
I do not think bpexit will catch a status 96 since bpbrd does not start. There are links to the technote at the bottom of this link.

http://forums.symantec.com/discussions/thread.jspa?threadID=67741&tstart=0

Lance_Hoskins
Level 6
And that's fine... I'm most concerned with status 1's, but thought I'd try catching more than just that if I could. I'm now just not sure how to put together the syntax to check for a specific policy AND status code. If I could figure out how to do an "AND" opperand or the "not equal" operand to work, I'd be all set!

zippy
Level 6
Lance,

Here

Look at this link

http://forums.symantec.com/discussions/thread.jspa?messageID=4443454촾

JD

Lance_Hoskins
Level 6
Ok Jim, I'm making you work for this one! :) I have it almost done, but need the syntax for the not equals opperand. I figured it would be != since equals is ==, but that doesn't seem to be working. Hook me up brother!

zippy
Level 6
Lance,


For Korn shell

http://www.google.com/search?hl=en&safe=off&sa=X&oi=spell&resnum=0&ct=result&cd=1&q=Korn+Shell+greater+than+or+equal+to+-get&spell=1

For batch
http://home.flash.net/~hoselton/pubs/mah_005.txt

JD

zippy
Level 6
Lance,

I have cron run this every day at 8:00 am, you wont need to fart around with greater than or equal too, just use what Veritas has given you and BLAT ans you be good.

Use the Oracle one at the bottome for your exchange server mail.

This is Korn Shell, but it is easy to convert it to BATCH.

JD

#!/usr/bin/ksh

#This script is used for giving daily statistics.The cronjob is set to run on a daily basis.
#Script created by James Dunn 2001
#set -vx
#Set variables


TODAY=`date +%a`
HOST=`hostname`
CURRDATE=`date +%m%d%y`
OUTFILE=/var/tmp/out2
OUTFILE1=/var/tmp/out1
OUTFILE2=/var/tmp/out2
OUTFILE3=/var/tmp/out3
ADMINCMD=/usr/openv/netbackup/bin/admincmd
BPIMAGELIST=/usr/openv/netbackup/bin/admincmd/bpimagelist
ERRORLIST=/usr/openv/netbackup/bin/admincmd/bperror
GOODIE=/usr/openv/netbackup/bin/goodies


# Clear /tmp/out2 file first
/bin/rm -rf $OUTFILE $OUTFILE1 $OUTFILE2 $OUTFILE3

if ; then
HARDWARE=`head -1 /usr/openv/netbackup/version | cut -f2 -d" "`
else
echo "/usr/openv/netbackup/version not found"
exit 1
fi

for i in $HOST
do

echo "
" >> $OUTFILE
$ADMINCMD/bperror -U -backstat -s info -hoursago 24 1>> $OUTFILE 2>&1
echo "
Recently Used Media:
" >> $OUTFILE
$BPIMAGELIST -A -media -hoursago 24 1>>$OUTFILE 2>&1

mailx -s "My Company's Backup list for `date +%x`" net_backup < $OUTFILE
#mailx -s "My Company's Backup list for `date +%x`" jd < $OUTFILE

$ERRORLIST -U -problems -hoursago 24 1>>$OUTFILE1 2>&1

#mailx -s "My Company's Backup errors for `date +%x`" net_backup < $OUTFILE1
mailx -s "My Company's Backup errors for `date +%x`" net_back_error < $OUTFILE1
mailx -s "My Company's Backup errors for `date +%x`" jd < $OUTFILE1

$ADMINCMD/bperror -U -backstat -by_statcode >> $OUTFILE2
mailx -s "My company's Backup by CODE for `date +%x`" net_backup < $OUTFILE2

$ADMINCMD/bpcatlist -server -client -since-days 1 >>$OUTFILE3
mailx -s "ORACLE SNAP BACKUPS for `date +%x`" oracle_snap < $OUTFILE3

done

Lance_Hoskins
Level 6
Beautiful code Jim. I got it working the hard way! ;) Below's what I added to my backup_exit_notify.cmd file. As Emeril would say, "BAM".



@if not "%2" == "P-Exchange-Stores" goto DoNothing

@if "%5" == "0" goto DoNothing

@if "%5" == "150" goto DoNothing

blat_me_an_email

:DoNothing

More difficult than it had to be, bu hey it's my first attempt at playing with NBU scripting--give me a break!

Lance