rman target / log=/u01/clover_db_bkp/clover_db_bkp.log <<EOF
RUN {
allocate channel c1 type DISK;
allocate channel c2 type DISK;
crosscheck backup;
crosscheck archivelog all;
delete noprompt expired backup;
sql 'alter system archive log current';
backup as compressed backupset database format '/u01/clover_db_bkp/%d_DB_%T_%s' ;
sql 'alter system archive log current';
backup as compressed backupset archivelog all format '/u01/clover_db_bkp/%d_ARCH_%T_%s' ;
copy current controlfile to '/u01/clover_db_bkp/%d_control_file';
#DELETE NOPROMPT OBSOLETE RECOVERY WINDOW OF 7 DAYS;
release channel c1;
release channel c2;
}
exit
EOF
******************************** SHELL SCRIPT *********************************
#########Hot Backup Using RMAN##########
. /d04_orahome/db/tech_st/11.1.0/<SID_HOSTNAME>.env
# Change directory to Oracle path
# Define environment
FOLDDATE_L0=`date +%d_%h_%y-%H%M`
SRCP=/d06_home/orahome/HotBackup/rman
DEST=/RMAN_BKP/RMAN_PROD
#RESP=/prodhotbkp/RMAN_HOT/RESPONSE
### It will delete old backup #####
cd /RMAN_BKP/Day_Old/.
rm -rf *
### It will move last week backup ###
cd /RMAN_BKP/RMAN_PROD/.
mv * /RMAN_BKP/Day_Old/.
mkdir -p $DEST/$FOLDDATE_L0/
# connect to target database
rman msglog $DEST/$FOLDDATE_L0/rman_HOT_incr_L0.log << EOF
connect target /
# Run Backup commands
run{
SQL 'alter system switch logfile';
SQL 'alter system switch logfile';
backup format '$DEST/$FOLDDATE_L0/DB_%d_%T_%t_%U.bak' incremental level 0 database;
SQL 'alter system switch logfile';
SQL 'alter system switch logfile';
SQL 'alter system switch logfile';
backup format '$DEST/$FOLDDATE_L0/ARCH_%d_%T_%t_%U.bak' archivelog from time 'sysdate-1';
backup format '$DEST/$FOLDDATE_L0/CTL_%d_%T_%t_%U.bak' current controlfile;
}
EOF
if [ $? -ne 0 ];
then
echo -e " Backup failed @ \c"
date
exit
else
echo -e "RMAN ran okay... @ \c"
date
fi
#----------------------------------------------
#sh $SRCP/rm_old_hot_incrL0_backups.sh
echo -e " The backup size for today is : \c"
du -sh $DEST/$FOLDDATE_L0
echo -e "\n\n"
#cp -p $DEST/$FOLDDATE_L0/rman_HOT_incr_L0.log $RESP/rman_HOT_incr_L0_$FOLDDATE_L0.log
#----------------------------------------------
exit
#----------------------------------------------
No comments:
Post a Comment