Home » RDBMS Server » Backup & Recovery » relationship between different instance in RMAN (oracle 9 )
relationship between different instance in RMAN [message #423890] Tue, 29 September 2009 01:42 Go to next message
chuikingman
Messages: 90
Registered: August 2009
Member
Hi,
I have a database and there are several instance in DB like FRWK RCA SAS rman.
I have below scrip to do database backup .
But in rman command it only target to rman.
So, in this script , will the instance FRWK ,RCA ,SAS will be backup ??
which part of script is doing that ???
Can you point out ???
I attach the script in here .
Below is the script :
#! /bin/ksh
###############################################
# #
# Script : db_oracle.bck #
# #
# Param : None #
# Description : #
# Use RMAN to Backup database <SID> #
# to BACKUP_DIR #
# #
###############################################

###############################################
# Customized Parameters
#
###############################################

# LIST_SID = List of Database to backup.
LIST_SID="FRWK RCA SAS"

# RMAN_SID = SID of RMAN Database
RMAN_SID=rman

# CONNECT_RMAN = Connect string of RMAN Database
CONNECT_RMAN="rman"

# RMAN_USER = Name of RMAN User Database
RMAN_USER="rman"

# RMAN_PASSWD = Password of RMAN User Database
RMAN_PASSWD="rman"

# BACKUP_DIR = directory used by RMAN to backup the files Database
BACKUP_DIR=/database/backup_data
export BACKUP_DIR

# SVG_DIR = Device to backup all files of database
SVG_DIR=/dev/rmt/0

# RMAN_DATAFILE_DIRECTORY_LIST = List of directories where RMAN database is installed
RMAN_DATAFILE_DIRECTORY_LIST="/database/oradata1/rman /database/oradata2/rman"

SCRIPT_DIRECTORY=/product/WarmBackup
LOG_DIRECTORY=/product/WarmBackup/log

# ORACLE_HOME =
ORACLE_HOME=/opt/oracle/product/9ir2

# End of section customized parameters
#############################################


DATE=`/usr/bin/date +%Y%m%d%OH%OM`
BACKUP_DATE=${DATE}

###############################
# ENVIRONNEMENT
###############################
# LD_LIBRARY_PATH=
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib
# SHLIB_PATH=
SHLIB_PATH=$SHLIB_PATH:$ORACLE_HOME/lib

PATH=$PATH:/usr/bin:$ORACLE_HOME/bin
NLS_LANG=american_america.UTF8
export NLS_LANG

export PATH
export ORACLE_HOME
export LD_LIBRARY_PATH
export SHLIB_PATH

##############################
# BEGIN BACKUP
##############################
# Log name
LOG_FILE=${LOG_DIRECTORY}/${BACKUP_DATE}_bck_db.log

# Creating log file to permission
/usr/bin/touch ${LOG_FILE}
/usr/bin/chmod ug+rw ${LOG_FILE}

DATE=`/usr/bin/date +"%x %X"`
/usr/bin/echo "${DATE}: Begin Backup ${BACKUP_DATE}" >> ${LOG_FILE}
/usr/bin/echo "" >> ${LOG_FILE}

# Create a new archive with a flag file
/usr/bin/echo "${BACKUP_DATE}" > ${LOG_DIRECTORY}/flag_${BACKUP_DATE}.file
/usr/bin/tar -cvpf ${SVG_DIR} ${LOG_DIRECTORY}/flag_${BACKUP_DATE}.file 1>>${LOG_FILE} 2>>${LOG_FILE}
if [ $? -eq 0 ]
then
/usr/bin/rm -f ${LOG_DIRECTORY}/flag_${BACKUP_DATE}.file
fi


##############################
# DATABASE(S) BACKUP
##############################
# For each database
for instance in $LIST_SID
do
ORACLE_SID=$instance
export ORACLE_SID

DATE=`/usr/bin/date +"%x %X"`
echo "${DATE}: Database ${ORACLE_SID}" >> ${LOG_FILE}

/usr/bin/echo "${DATE}: Tar init${ORACLE_SID}.ora on ${SVG_DIR}" >> ${LOG_FILE}
/usr/bin/tar -rhvfp ${SVG_DIR} ${ORACLE_HOME}/dbs/init${ORACLE_SID}.ora 1>>${LOG_FILE} 2>>${LOG_FILE}
/usr/bin/echo "" >> ${LOG_FILE}

# Execute RMAN command to Backup
DATE=`/usr/bin/date +"%x %X"`
/usr/bin/echo "${DATE}: Execute RMAN command" >> ${LOG_FILE}

# Build full backup script
/usr/bin/touch ${LOG_DIRECTORY}/~db_full_backup.rman
/usr/bin/chmod ug+rw ${LOG_DIRECTORY}/~db_full_backup.rman
export dir_tmp=`echo $BACKUP_DIR|sed -e "s:\/:\\\\\/:g"`
sed -e "s/%BACKUP_DIR%/`echo $dir_tmp`/g" $SCRIPT_DIRECTORY/script/db_full_backup.rman >> ${LOG_DIRECTORY}/~db_full_backup.rman

# Execute RMAN command to Backup
DATE=`/usr/bin/date +"%x %X"`
/usr/bin/echo "${DATE}: Execute RMAN command" >> ${LOG_FILE}
$ORACLE_HOME/bin/rman target / catalog ${RMAN_USER}/${RMAN_PASSWD}@${CONNECT_RMAN} @${LOG_DIRECTORY}/~db_full_backup.rman >> ${LOG_FILE}

# Delete temporary script file
rm -f ${LOG_DIRECTORY}/~db_full_backup.rman

# Move Oracle Bakup File Set to SVG_DIR
DATE=`/usr/bin/date +"%x %X"`
/usr/bin/echo "${DATE}: Tar Backup File to ${SVG_DIR}" >> ${LOG_FILE}
cd ${BACKUP_DIR}
/usr/bin/tar -rvpf ${SVG_DIR} ./ 1>>${LOG_FILE} 2>>${LOG_FILE}
if [ $? -eq 0 ]
then
/usr/bin/echo "Suppress Backup File to ${BACKUP_DIR}" >> ${LOG_FILE}
/usr/bin/rm -f ${BACKUP_DIR}/* 1>>${LOG_FILE} 2>>${LOG_FILE}
fi

/usr/bin/echo "" >> ${LOG_FILE}
done

##############################
# Backup RMAN Database Catalog
##############################
# Shutdown RMAN Database Catolog if on same server
ORACLE_SID=${RMAN_SID}
export ORACLE_SID

demarre=`ps -ef | grep ${ORACLE_SID} | grep ora_ | grep -v grep | wc -l`
if [ ${demarre} -le 4 ]
then
/usr/bin/echo "RMAN Database ${ORACLE_SID} is on another server" >>${LOG_FILE}
/usr/bin/echo "No backup can be done..." >>${LOG_FILE}
# Date of end Backup
DATE=`/usr/bin/date +"%x %X"`
/usr/bin/echo "End of Backup at ${DATE}" >> ${LOG_FILE}
exit
fi

DATE=`/usr/bin/date +"%x %X"`
/usr/bin/echo "${DATE}: Backup RMAN database" >> ${LOG_FILE}
/usr/bin/echo "" >> ${LOG_FILE}

/usr/bin/echo "Shutdown RMAN database : ${ORACLE_SID}" >> ${LOG_FILE}
$ORACLE_HOME/bin/sqlplus -s "/ as sysdba" <<EOF 1>>${LOG_FILE} 2>>${LOG_FILE}
shutdown immediate
EOF

# Backup database files
cd ${BACKUP_DIR}
RMAN_TAR=${BACKUP_DIR}/rman_${BACKUP_DATE}.tar
DATE=`/usr/bin/date +"%x %X"`
/usr/bin/echo "${DATE}: Backup database files" >> ${LOG_FILE}

/usr/bin/tar -cvfp ${RMAN_TAR} ${RMAN_DATAFILE_DIRECTORY_LIST} 1>>${LOG_FILE} 2>>${LOG_FILE}

# Inititialization files
DATE=`/usr/bin/date +"%x %X"`
/usr/bin/echo "${DATE}: Backup initialization file" >> ${LOG_FILE}
/usr/bin/tar -rhvfp ${RMAN_TAR} ${ORACLE_HOME}/dbs/init${ORACLE_SID}.ora 1>>${LOG_FILE} 2>>${LOG_FILE}

# Startup RMAN Database Catolog
DATE=`/usr/bin/date +"%x %X"`
echo "${DATE}: Startup RMAN database : ${ORACLE_SID}" >> ${LOG_FILE}
$ORACLE_HOME/bin/sqlplus -s "/ as sysdba" <<EOF 1>>${LOG_FILE} 2>>${LOG_FILE}
startup
EOF

# Tar RMAN on SVG_DIR
DATE=`/usr/bin/date +"%x %X"`
/usr/bin/echo "${DATE}: Tar Backup RMAN on ${SVG_DIR}" >> ${LOG_FILE}
/usr/bin/tar -rvfp ${SVG_DIR} rman_${BACKUP_DATE}.tar 1>>${LOG_FILE} 2>>${LOG_FILE}
if [ $? -eq 0 ]
then
/usr/bin/echo "Remove ${RMAN_TAR}" >> ${LOG_FILE}
/usr/bin/rm -f ${RMAN_TAR} 1>>${LOG_FILE} 2>>${LOG_FILE}
fi

# Date of end Backup
DATE=`/usr/bin/date +"%x %X"`
echo "End of Backup at ${DATE}" >> ${LOG_FILE}

Re: relationship between different instance in RMAN [message #423891 is a reply to message #423890] Tue, 29 September 2009 01:47 Go to previous messageGo to next message
Michel Cadot
Messages: 63810
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Quote:
But in rman command it only target to rman.

Wrong, it is target "/" that is current ORACLE_SID database. RMAN one is the catalog.
Target is each database in LIST_SID that is FRWK RCA SAS.

Regards
Michel
Re: relationship between different instance in RMAN [message #423892 is a reply to message #423891] Tue, 29 September 2009 02:03 Go to previous messageGo to next message
chuikingman
Messages: 90
Registered: August 2009
Member
Hi,
so, in the script , it is target to FRWK ,RCA , SAS in sequence ???
it is the same command as
rman traget / FRWK
rman target / RCA
rman target / SAS

is it right ???
Re: relationship between different instance in RMAN [message #423893 is a reply to message #423891] Tue, 29 September 2009 02:06 Go to previous messageGo to next message
chuikingman
Messages: 90
Registered: August 2009
Member
Hi
so ,
$ORACLE_HOME/bin/rman target / catalog ${RMAN_USER}/${RMAN_PASSWD}@${CONNECT_RMAN} @${LOG_DIRECTORY}/~db_full_backup.rman >> ${LOG_FILE}

it is target as " / " only , not rman instance ????

it is right ???
Re: relationship between different instance in RMAN [message #423894 is a reply to message #423892] Tue, 29 September 2009 02:08 Go to previous messageGo to next message
Michel Cadot
Messages: 63810
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Quote:
so, in the script , it is target to FRWK ,RCA , SAS in sequence ???

Yes.

Regards
Michel
Re: relationship between different instance in RMAN [message #423895 is a reply to message #423893] Tue, 29 September 2009 02:10 Go to previous message
Michel Cadot
Messages: 63810
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Quote:
it is target as " / " only , not rman instance ????

It target / and use catalog in rman instance.

I think you should read Database Backup and Recovery Basics.

Regards
Michel
Previous Topic: ORACLE data block corrupted
Next Topic: add sql_trace in rman instance
Goto Forum:
  


Current Time: Thu Sep 29 14:08:46 CDT 2016

Total time taken to generate the page: 0.20916 seconds