RMAN clone modules

This is just a snippet from my main RMAN backup script that I use for building
an RMAN clone text file as well as copying over the RMAN backups.


#=-=-=-=-=-=-=-=-=-=-=
# grab the SCN needed for the clone
#=-=-=-=-=-=-=-=-=-=-=
#
$SQL /nolog <<EOF
connect repo/PASSWD#1@emrep
set feedback off heading off pages 0 trims on
column checkpoint_change# format 99999999999999
spool $LOG_DIR/scn.tmp
#
SELECT min(checkpoint_change#) checkpoint_change# from RC_BACKUP_CONTROLFILE where db_name = ‘${DB_NAME}’;
#
spool off;
exit;
EOF
#
sed -e ‘/^SQL/d’ -e ‘s/^ \{1,\}//g’ $LOG_DIR/scn.tmp > $LOG_DIR/scn.txt
SCN=`cat $LOG_DIR/scn.txt`
#
#
#=-=-=-=-=-=-=-=-=-=-=
# build a quick rman script
#=-=-=-=-=-=-=-=-=-=-=
#
set tstct90 devct90 trnct90 demct90
for i in $*
do
   echo “run {” > $RUN_THIS-${i}.txt
   echo “allocate auxiliary channel c1 type disk;” >> $RUN_THIS-${i}.txt
   echo “allocate auxiliary channel c2 type disk;” >> $RUN_THIS-${i}.txt
   echo “set until SCN $SCN;” >> $RUN_THIS-${i}.txt
   echo “duplicate target database to ${i};” >> $RUN_THIS-${i}.txt
   echo “}” >> $RUN_THIS-${i}.txt
done
#
rm $LOG_DIR/scn*
#
#=-=-=-=-=-=-=-=-=
# remove old RMAN backup on nrac01
#=-=-=-=-=-=-=-=-=
#
ssh nrac01 rm $RMAN_DIR/\*
#
#=-=-=-=-=-=-=-=-=
# copy RMAN backup to nrac01
#=-=-=-=-=-=-=-=-=
#
scp $RMAN_DIR/* nrac01:$RMAN_DIR
#
echo “rmanback on nrac01 after the SCP for ${DB_NAME}” > $LOG_DIR/nrac.tmp
echo “” >> $LOG_DIR/nrac.tmp
echo “” >> $LOG_DIR/nrac.tmp
ssh nrac01 ls -l $RMAN_DIR >> $LOG_DIR/nrac.tmp
mail -s “nrac01 ${DB_NAME} info” jim-bob@abc.com < $LOG_DIR/nrac.tmp
#

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s