Skip to Main Content

Database Software

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Simple bash/RMAN script fails

TheLonelyDBANov 19 2015 — edited Nov 19 2015

Hi,

I have this script. The one that fails is when I try to use ORACLE_HOME of our 9i installation. I get this in the RMAN log:

connected to target database (not started)
connected to recovery catalog database

RMAN> run
2> {
3>   backup incremental level 0 database plus archivelog delete input;
4> delete noprompt obsolete;
5> }
6>

Starting backup at 19-NOV-15
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of backup command at 11/19/2015 10:25:00
RMAN-06403: could not obtain a fully authorized session
ORA-01034: ORACLE not available
ORA-27101: shared memory realm does not exist
SVR4 Error: 2: No such file or directory

#!/bin/bash

#orgPATH=$PATH
type=$1
ts=$(date "+%Y%m%d %H:%m")
weekday=$(date +%a)

#script=$(readlink -f $0)
scriptDir=/oracle/app/oracle/admin/scripts/backup

log=$scriptDir/log/logfile_rman.log

if [ "$type" = "INC" ]; then
        rmanScript=$scriptDir/inc_backup.rman
        rmanScriptnine=$scriptDir/inc_9backup.rman
elif [ "$type" = "FULL" ]; then
        rmanScript=$scriptDir/full_backup.rman
        rmanScriptnine=$scriptDir/full_9backup.rman
else
        echo "$ts Type \"$type\" is not a valid value or empty, use INC or FULL"  >> $log
        exit 1
fi


for entry in $(grep -v ^# /var/opt/oracle/oratab|cut -d: -f1,2); do
        ts=$(date "+%Y%m%d %H:%M")
        export ORACLE_SID=$(echo $entry|cut -d: -f1)
        export ORACLE_HOME=$(echo $entry|cut -d: -f2)
        export PATH=/usr/bin:$ORACLE_HOME/bin
        rmantarget=$(echo $entry|cut -d: -f1)
#       rmannine=$(echo $entry|cut -d: -f2)
        blog=$scriptDir/log/${ORACLE_SID}_${type}_$weekday.log

        echo "$ts Starting rman $type backup of $ORACLE_SID"  >> $log


        if [ $rmantarget = "RMANDB" ]; then

                rman target / cmdfile=$rmanScript log=$blog  2>&1 > /dev/null

        elif [ $ORACLE_HOME = "/oracle/app/oracle/product/9.2/dbhome_1" ]; then

                rman target / catalog rmanowner/password@RMANDB cmdfile=$rmanScriptnine log=$blog  2>&1 > /dev/null

        else
                 rman target / catalog rmanowner/password@RMANDB cmdfile=$rmanScript log=$blog  2>&1 > /dev/null
        fi

        res=$?
        grep RMAN- $blog >> $log
        ts=$(date "+%Y%m%d %H:%M")
        if [ $res -ne 0 ]; then
                echo "$ts Error: rman returned Error for $ORACLE_SID "  >> $log
        else
                echo "$ts Completed rman $type backup of $ORACLE_SID" >> $log
        fi
done
echo "-------------------------------------------------" >> $log

I can see that for some reason, its starts rman without setting the SID? I have ran this manually and that worked fine.

Any ideas?

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 17 2015
Added on Nov 19 2015
21 comments
5,183 views