Shell Script Backup oracle database by rman full online with archive to disk

** Myself
export RMAN_DIR=/oraback
export FILE_DIR=${RMAN_DIR}/backup
export LOGDIR=${RMAN_DIR}/log
export RMAN_LOG=$LOGDIR/rman_backup_$ORACLE_SID`date +%d%h%y_%H%M`.log
export RMAN_ERR=$LOGDIR/rman_backup_$ORACLE_SID`date +%d%h%y_%H%M`.err
############# Backup config profile,and network files) ############
cp -Rp ${ORACLE_HOME}/dbs ${FILE_DIR}
cp -Rp ${ORACLE_HOME}/network/admin ${FILE_DIR}
############# Delete old archivelog last 2 date####################
rman nocatalog LOG = $RMAN_LOG APPEND<<END_SQL
connect target;
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '${FILE_DIR}/%F';
crosscheck archivelog all;
allocate channel for maintenance device type disk;
delete noprompt obsolete recovery window of 2 days;
release channel;
exit
END_SQL
############# Hot Backup database #################################
rman nocatalog LOG = $RMAN_LOG APPEND<<END_SQL
connect target;
run {
set command id to 'rman';
allocate channel t1 type disk;
backup
filesperset 5
format '${FILE_DIR}/df_%t_%s_%p'
database;
release channel t1;
}
exit
END_SQL
############# Switch archive redo to archive files ################
rman nocatalog LOG = $RMAN_LOG APPEND<<END_SQL
connect target;
sql 'alter system switch logfile';
exit
END_SQL
############# Backup archive logs #################################
rman nocatalog LOG = $RMAN_LOG APPEND<<END_SQL
connect target;
run {
set command id to 'rman';
  allocate channel t1 type disk;
backup
filesperset 5
format '${FILE_DIR}/df_%t_%s_%p'
archivelog all;
release channel t1;
}
exit
END_SQL
echo "backup $ORACLE_SID finish at $(date)">>$RMAN_LOG

0 comments:

Loading