If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Return codes from backup command

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-12-10, 07:48
hazy_dba hazy_dba is offline
Registered User
 
Join Date: Dec 2009
Posts: 40
Return codes from backup command

AIX - DB2 v9

I have inherited a script that does online backups to TSM for our DB2 databases.

Code:
    db2 backup db ${DB} online use TSM
    ret=$?
    if [ ${ret} != 0 ]; then
        exit 2
    fi
Which sometimes returns this:

Code:
db2_online_maint[28] db2 backup db dp2 online use TSM

Backup successful. The timestamp for this backup image is : 20101111233051

SQL2425W  The log file for the online backup was not truncated.
db2_online_maint[29] ret=2
db2_online_maint[30] [ 2 != 0 ]
db2_online_maint[31] exit 2
According to SQL2425W explanation I don't have to do anything.

The script however currently sees this as an error, and I would like to catch this particular message and not let the script exit 2 in the if statement.

This line, db2_online_maint[29] ret=2 is catching 2 from the db2 online backup (it would be 0 if there were no messages) but I don't know if it is returning 2 just for SQL2425W or it returns 2 for a number of different messages of a similar nature / warning level, some of which I may want to act upon and some I don't.

So, I'm not sure I want to change the script to ignore any messages that return the value 2. It would help if I knew what messages that get returned from db2 backup command map to what numeric values.

E.g.

no message - 0
SQL2425W - 2

etc.

Thank you for taking the time to have a look.
Reply With Quote
  #2 (permalink)  
Old 11-12-10, 08:12
nvk@vhv nvk@vhv is offline
Registered User
 
Join Date: Jan 2010
Posts: 294
Hmm,

i'ld do it like this

MSG=$(db2 backup db dp2 online use TSM)
echo $MSG
echo $MSG | grep "Backup successful" > /dev/null
if [ $? != 0 ]; then
exit 2
fi
exit 0
Reply With Quote
  #3 (permalink)  
Old 11-12-10, 09:00
hazy_dba hazy_dba is offline
Registered User
 
Join Date: Dec 2009
Posts: 40
Yes! I like that. That is just the sort of thing that will fix this. I am going to give that a go on one of our dev environments.

Thank you for showing me some scripting in a DB2 forum!

Reply With Quote
  #4 (permalink)  
Old 11-12-10, 10:36
Cougar8000 Cougar8000 is offline
Registered User
 
Join Date: Nov 2005
Location: IL
Posts: 554
When you check for !=0 you are not only picking up errors, you are also picking up warning msg's. To avoid picking warning msg's add a check for !=2 2 is a warning msg
__________________
--
IBM Certified DBA on DB2 for Linux, UNIX, and Windows

DB2 v9.1.0.2 os 5.3.0.0
Reply With Quote
  #5 (permalink)  
Old 11-16-10, 03:43
hazy_dba hazy_dba is offline
Registered User
 
Join Date: Dec 2009
Posts: 40
Quote:
Originally Posted by Cougar8000 View Post
When you check for !=0 you are not only picking up errors, you are also picking up warning msg's. To avoid picking warning msg's add a check for !=2 2 is a warning msg
I changed the script to do this in the end. I tried the MSG option but for some reason the syntax wouldn't work on our server. I won't forget it though, there are plenty of other maintenance scripts that could use some polish!

Thank you both for your help.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On