RE: Can I pass a parameter into an RMAN Script?

I've never figured out how to do that, if it's possible.  However, one
workaround is to simply build the RMAN script each time you run a
backup.  Then you can pass the parameter to the shell script.  Below is
an example of what I do and though I don't pass in the ORACLE_SID, it
could be easily modified to do that.  I also put the resultant script at
the end.  Hope this formats correctly.

-joe

<snip>
# Set correct Oracle environment
export ORACLE_BASE=/opt/app/oracle
export NLS_LANG=AMERICAN_AMERICA.UTF8
export PATH=$ORACLE_HOME/bin:$ORACLE_HOME/OPatch:$PATH
ORACLE_HOME=/opt/app/oracle/product/10.2.0
ORACLE_SID=iap1
ORACLE_USER=oracle
TNS_ADMIN=/var/opt/oracle
export ORACLE_HOME ORACLE_SID ORACLE_USER TNS_ADMIN

# Set the RMAN environment
RMAN=rman       # RMAN executable name
RMAN_USER=rman  # Owner of the RMAN schema
RMAN_PWRD=rman  # Password for the RMAN_USER
RMAN_TNS=rcat   # tnsname for the recovery catalog database
RMAN_SCRIPT=/home/oracle/scripts/rman/rman_full.rcv
export RMAN RMAN_USER RMAN_PWRD RMAN_TNS RMAN_SCRIPT

# Miscellaneous
SEND_TO=jsweetser@xxxxxxxx
HOST=`hostname -s`
export SEND_TO HOST

# Build the recovery manager script to used.  The script is built here
# to give greater control of the TAG name used in it.  This TAG is
displayed
# in RMAN commands like "list backup summary".
echo "connect target /" > $RMAN_SCRIPT
echo "connect rcvcat $RMAN_USER/$RMAN_PWRD@$RMAN_TNS" >> $RMAN_SCRIPT
echo "" >> $RMAN_SCRIPT
echo "run {" >> $RMAN_SCRIPT
echo "allocate channel c1 type disk;" >> $RMAN_SCRIPT
echo "sql 'alter system switch logfile';" >> $RMAN_SCRIPT
echo "backup" >> $RMAN_SCRIPT
echo "  incremental level 0" >> $RMAN_SCRIPT
echo "  filesperset 10" >> $RMAN_SCRIPT
echo "  format
'/u04/oradata/backup/${ORACLE_SID}/data/${ORACLE_SID}_%U'" >>
$RMAN_SCRIPT

# Here is where we build the tag name
DayOfWeek=`date +%w`
case $DayOfWeek in
    0) TAG=SUN_DB_L0_`date +%b_%d_%Y_%H%M%p`
       ;;
    1) TAG=MON_DB_L0_`date +%b_%d_%Y_%H%M%p`
       ;;
    2) TAG=TUE_DB_L0_`date +%b_%d_%Y_%H%M%p`
       ;;
    3) TAG=WED_DB_L0_`date +%b_%d_%Y_%H%M%p`
       ;;
    4) TAG=THU_DB_L0_`date +%b_%d_%Y_%H%M%p`
       ;;
    5) TAG=FRI_DB_L0_`date +%b_%d_%Y_%H%M%p`
       ;;
    6) TAG=SAT_DB_L0_`date +%b_%d_%Y_%H%M%p`
       ;;
esac
echo "  tag $TAG" >> $RMAN_SCRIPT

echo "  database plus archivelog delete input;" >> $RMAN_SCRIPT

echo "sql 'alter database backup controlfile to trace';" >> $RMAN_SCRIPT
echo "release channel c1;" >> $RMAN_SCRIPT
echo "}" >> $RMAN_SCRIPT

# Write the command we will use out to the log file.
echo
echo "% ${ORACLE_HOME}/bin/$RMAN cmdfile '$RMAN_SCRIPT'"
echo

${ORACLE_HOME}/bin/$RMAN cmdfile "$RMAN_SCRIPT"

RETURN_STATUS=$?

And the RMAN script is:
connect target /
connect rcvcat rman/rman@rcat

run {
allocate channel c1 type disk;
sql 'alter system switch logfile';
backup
  incremental level 0
  filesperset 10
  format '/u04/oradata/backup/iap1/data/iap1_%U'
  tag MON_DB_L0_Feb_25_2008_0225AM
  database plus archivelog delete input;
sql 'alter database backup controlfile to trace';
release channel c1;
}
________________________________

From: oracle-l-bounce@xxxxxxxxxxxxx
[mailto:oracle-l-bounce@xxxxxxxxxxxxx] On Behalf Of Sam Bootsma
Sent: Monday, February 25, 2008 10:45 AM
To: oracle-l@xxxxxxxxxxxxx
Subject: Can I pass a parameter into an RMAN Script?



Hello all,

 

Oracle 10.2.0.3, Enterprise Edition, on AIX 5.3.

 

In our RMAN backup scripts for our AAA database we have several format
lines that look like:

format '/san2/orabackup/AAA/CTRL_%d_%T_%p_%s%t';

 

The same lines for our BBB database looks like:

format '/san2/orabackup/BBB/CTRL_%d_%T_%p_%s%t';

 

Because of this difference in the format lines I need to create and
maintain separate RMAN scripts for each database.  If I could pass a
parameter into the RMAN script, then I could have just one RMAN script
and call it with a parameter specifying the database name.

 

Can anybody tell me if this is possible?  Or must I continue to create
separate RMAN scripts for each database I wish to backup?  I checked the
Oracle docs, but could not find anything that spoke to what I want to
do.

 

Thanks,

 

Sam Bootsma

Oracle Database Administrator

Information Technology Services
George Brown College

Phone: 416-415-5000 x4933
Fax: 416-415-4836
E-mail: sbootsma@xxxxxxxxxxxxxx <mailto:sbootsma@xxxxxxxxxxxxxx> 

 

 
Confidentiality Note: This message contains information that may be 
confidential and/or privileged. If you are not the intended recipient, you 
should not use, copy, disclose, distribute or take any action based on this 
message. If you have received this message in error, please advise the sender 
immediately by reply email and delete this message. Although ICAT Managers, LLC 
scans e-mail and attachments for viruses, it does not guarantee that either are 
virus-free and accepts no liability for any damage sustained as a result of 
viruses.  Thank you.

--
http://www.freelists.org/webpage/oracle-l


Other related posts: