LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-06-2005, 09:08 AM   #1
kal2005
LQ Newbie
 
Registered: Jul 2005
Posts: 5

Rep: Reputation: 0
I need help with this script - it is weird


validate_backup()
{
# To validate the success of the backup

notify -l "Validating rman backup job ..."

RMN_STATUS=`grep "Recovery Manager complete" $RMN_LOG_FILE | tail -1 | nawk '{print $3 }'`;

if [ $DEBUG = "ON" ]; then
echo RMN_STATUS : $RMN_STATUS
fi

if [ "${RMN_STATUS}" = "complete." ];
then
notify -l "RMAN BACKUP JOB `basename ${RMN_CMD_FILE}` SUCCESSFUL !!!"
else
notify -blm "RMAN BACKUP JOB `basename ${RMN_CMD_FILE}` FAILED !!!"
exit ${EXIT3};
fi

return;
}

where ${RMN_CMD_FILE} is what you see below in the log file:


[07/05/05-01:05:02] Starting /u01/app/oracle/product/9.2.0/bin/rman /u01/app/oracle/admin/cbep2/rman/full_hbk_disk.rcv ...
[07/05/05-01:06:12] Validating rman backup job ...
[07/05/05-01:06:12] RMAN BACKUP JOB archive_all_disk.rcv SUCCESSFUL !!!
[07/05/05-01:06:12] mv /u01/app/oracle/admin/cbep2/rman/logs/full_hbk_disk.rcv.log /u01/app/oracle/admin/cbep2/rman/logs/full_hbk
_disk.rcv.logO
[07/05/05-01:06:13] Starting /u01/app/oracle/product/9.2.0/bin/rman /u01/app/oracle/admin/cbep2/rman/full_hbk_disk.rcv ...
[07/05/05-06:02:09] Validating rman backup job ...
[07/05/05-06:02:10] RMAN BACKUP JOB full_hbk_disk.rcv FAILED !!!
[07/05/05-06:16:42] Validating rman backup job ...
[07/05/05-06:16:42] RMAN BACKUP JOB full_hbk_disk.rcv SUCCESSFUL !!!
[07/05/05-06:16:42] Completed onlinerman V.1.0

We have several Oracle instances that we back up using RMAN. We have cronjobs for those RMAN jobs to run. The script that is run call the above function to validate and send page depending on the status of the RMAN. For only two of the instances we get paged that "RMAN BACKUP JOB blablabla FAILED !!!", but in fact it did not fail. As we can see in the log , after about 14 minutes, that it was SUCCESSFUL.
When we check backup logs everything looks all right. I do not see any problem with the script as well. Any idea why do we get paged?

Any input will be appreciated!
Kal

Last edited by kal2005; 07-06-2005 at 10:11 AM.
 
Old 07-06-2005, 03:10 PM   #2
vladmihaisima
Member
 
Registered: Oct 2002
Location: Delft, Netherlands
Distribution: Gentoo
Posts: 196

Rep: Reputation: 33
Could you please post also the file on which you apply grep ?
 
Old 07-06-2005, 03:55 PM   #3
kal2005
LQ Newbie
 
Registered: Jul 2005
Posts: 5

Original Poster
Rep: Reputation: 0
$ tail full_hbk_disk.rcv.log

released channel: CBE_CHNL_2

released channel: CBE_CHNL_3

released channel: CBE_CHNL_4

host command complete

Recovery Manager complete.
 
Old 07-06-2005, 04:19 PM   #4
vladmihaisima
Member
 
Registered: Oct 2002
Location: Delft, Netherlands
Distribution: Gentoo
Posts: 196

Rep: Reputation: 33
Now a quesition about the script. The command:

RMN_STATUS=`grep "Recovery Manager complete" $RMN_LOG_FILE | tail -1 | nawk '{print $3 }'`;

will always put in RMN_STATUS complete, unless the file is $RMN_LOG_FILE is overwritten. Is this the case ?

Why don't you set DEBUG to on ? (like DEBUG=ON)

And I think the if should be:

if [ "$DEBUG" = "ON" ]; then
echo RMN_STATUS : $RMN_STATUS
fi
 
Old 07-06-2005, 04:54 PM   #5
kal2005
LQ Newbie
 
Registered: Jul 2005
Posts: 5

Original Poster
Rep: Reputation: 0
Yes I have that as well. The entire script is too large.


create_log_file_name()
{
# Retrieve the rman cmdfile and construct the logfile name.

RMN_CMD_FILE=$1

base_name=`basename ${RMN_CMD_FILE} | sed -e 's/\.cmd//'`
RMN_LOG_FILE=${RMN_LOG_DIR}/${base_name}.log

if [ $DEBUG = "ON" ]; then
echo RMN_LOG_FILE : $RMN_LOG_FILE
fi

if [ -z "${RMN_LOG_FILE}" ];
then
notify -blm "** ERROR: Unable to set RMN_LOG_FILE"
exit ${EXIT2};
fi

if [ -f "${RMN_LOG_FILE}" ];
then
notify -l "mv $RMN_LOG_FILE ${RMN_LOG_FILE}O"
mv $RMN_LOG_FILE ${RMN_LOG_FILE}O > /dev/null
fi

return;
}
 
Old 07-06-2005, 11:27 PM   #6
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,360

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
When you run the validate..() , it's possible that the backup logwriter has not completely finished ie some output is still buffered in memory, not yet output to disk.
Try printing the value for ${RMN_STATUS} when it fails.
 
Old 07-07-2005, 08:41 AM   #7
kal2005
LQ Newbie
 
Registered: Jul 2005
Posts: 5

Original Poster
Rep: Reputation: 0
That sounds good, can I put some kind of delay before calling the function? If so can you please give me an example how can I fit that into the calling environment below:

#####
#
# MAIN ROUTINE
#
#####

REV="1.0"
HOST=`uname -n`
PROG=`basename $0`
ORA_HOST=`hostname`
# Set a variable that corresponds to 'whitespace'. This variable should
# contain a space and a tab. In 'vi', 'set list' will show the following:
#
# WS=" ^I"$
#
WS=" "

# Create some variables to simplify regular expression evaluations
#
# WA - Any number of white space character(s)including 0
# WN - Any character(s) including none except white space character(s)
# W1 - At least 1 white space character(s)
#
WA="[$WS]*"
WN="[^$WS]*"
W1="[$WS]+"

# Exit codes
#
# EXIT0 Backup Successful
# EXIT1 Usage error or execution termination by the user
# EXIT2 Missing executables or unset environment variables
# EXIT3 Backup Unsucessful
#
EXIT0=0
EXIT1=1
EXIT2=2
EXIT3=3

#
# Begin
#


if [ $# -eq 0 ];
then
usage;
fi

while getopts ":s:a:b:d" OPTM "$@"
do
case "${OPTM}" in
s) SID=${OPTARG};;
a) ARC_SCRIPT=${OPTARG}
S_SCRIPT=${OPTARG}
ARC_OBK='Y';;
o) ORA_SCRIPT=${OPTARG}
S_SCRIPT=${OPTARG}
ORA_OBK='Y';;
b) BPERSON=`cat /com/oracle/omon/config/on_call_dba`;;
d) DEBUG="ON";;
*) notify -p "**ERROR : Invalid option -${OPTARG}"
usage;;
esac
done

set_def_vars;
set_local_env;
notify -l "Starting onlinerman V.${REV}"

set_ora_env;
set_rman_env;
chk_plus;
chk_rman;
# chk_oracle;

if [ ${ARC_OBK} = 'Y' ];
then
chk_arc_rman_script;
fi

if [ ${ORA_OBK} = 'Y' ];
then
chk_ora_rman_script;
fi

if [ ${ARC_OBK} = 'Y' ];
then
create_log_file_name "${RMN_ARC_SCRIPT}";
run_rman "${RMN_ARC_SCRIPT}";
if [ $? -eq 0 ];
then
validate_backup;
fi
fi

if [ ${ORA_OBK} = 'Y' ];
then
create_log_file_name "${RMN_ORA_SCRIPT}";
run_rman "${RMN_ORA_SCRIPT}";
if [ $? -eq 0 ];
then
validate_backup;
fi
fi

notify -l "Completed onlinerman V.${REV}"
cp $RMN_LOG_DIR/${OJOB}.rcv.log /dbbackup/oracle/backup/$SID
exit ${EXIT0};

#----------------------------------------------------------------------------

Appreciate
Kal
 
  


Reply



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



Similar Threads
Thread Thread Starter Forum Replies Last Post
weird, weird problems with logitech precision USB gamepad ikataii Linux - Hardware 4 10-14-2005 04:31 AM
Need help with the script - it is weird kal2005 Solaris / OpenSolaris 1 07-05-2005 05:12 PM
Weird, weird apache2 problem atheist Debian 1 09-17-2004 08:26 PM
my adding user script seems weird and buggy nzx Programming 1 10-21-2003 07:29 AM
bash script connect from one host to another and to another weird aim nakkaya Linux - Networking 1 06-30-2003 01:28 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:33 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration