Tuesday, July 17, 2018

Level 1 RMAN Backup Script

==========In hpux=======
export ORACLE_BASE=/u02/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0.4/dbhome_1
export ORACLE_SID=dcpdb1
export PATH=$ORACLE_HOME/bin:$PATH
export TZ=GMT6

dt=`date '+%d%m%Y%H%M'`

LOG_FILE=/db_rmanbackup/rman_logs/${ORACLE_SID}_DAILY_LEVEL1_BACKUP_${dt}.log
echo "DCPDB DAILY LEVEL 1 BACKUP STARTED on `date` " >$LOG_FILE
rman  <<! >>$LOG_FILE
connect target rmanbkp/rmanbkp
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS;
CONFIGURE ARCHIVELOG DELETION POLICY TO APPLIED ON ALL STANDBY;
sql 'alter system archive log current';
RUN
{
allocate channel c1  type disk;
allocate channel c2  type disk;
allocate channel c3  type disk;
allocate channel c4  type disk;
allocate channel c5  type disk;
allocate channel c6  type disk;
allocate channel c7  type disk;
sql "alter system switch logfile";
backup incremental level 1 cumulative AS COMPRESSED BACKUPSET database tag 'LEV1_T24_DB_$dt' format '/db_rmanbackup/t24_db_l1_%p_%s_$dt.bkp';
backup AS COMPRESSED BACKUPSET archivelog all tag 'daily_arch_bkp_disk' format '/db_rmanbackup/t24_arch_l1_%p_%s_$dt.bkp';
backup current controlfile tag T24_CTL_$dt format '/db_rmanbackup/t24_ctl_l1_%p_%s_$dt.bkp';
backup spfile tag T24_SPF_$dt format '/db_rmanbackup/t24_spf_l1_%p_%s_$dt.bkp';
CROSSCHECK BACKUP;
CROSSCHECK ARCHIVELOG ALL;
delete force noprompt archivelog until time 'sysdate -3';
DELETE NOPROMPT OBSOLETE RECOVERY WINDOW OF 7 DAYS;
release channel c1;
release channel c2;
release channel c3;
release channel c4;
release channel c5;
release channel c6;
release channel c7;
}
!
echo "DCPDB LEVEL 1 BACKUP FINISHIED on  `date` " >>$LOG_FILE

exit 0

=======in linux========
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0.4.0/dbhome_1
export ORACLE_SID=remitdb
export PATH=$ORACLE_HOME/bin:$PATH
#export TZ=GMT6

dt=`date '+%d%m%Y%H%M'`

LOG_FILE=/qpay_rmanbackup/rman_logs/${ORACLE_SID}_DAILY_LEVEL1_BACKUP_${dt}.log
echo "DCPDB DAILY LEVEL 1 BACKUP STARTED on `date` " >$LOG_FILE
rman  <<! >>$LOG_FILE
connect target rmanbkp/rmanbkp
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS;
CONFIGURE ARCHIVELOG DELETION POLICY TO APPLIED ON ALL STANDBY;
sql 'alter system archive log current';
RUN
{
allocate channel c1  type disk;
allocate channel c2  type disk;
sql "alter system switch logfile";
backup incremental level 1 cumulative AS COMPRESSED BACKUPSET database tag 'LEV1_QPAY_DB_$dt' format '/qpay_rmanbackup/qpay_db_l1_%p_%s_$dt.bkp';
backup AS COMPRESSED BACKUPSET archivelog all tag 'daily_arch_bkp_disk' format '/qpay_rmanbackup/qpay_arch_l1_%p_%s_$dt.bkp';
backup current controlfile tag QPAY_CTL_$dt format '/qpay_rmanbackup/qpay_ctl_l1_%p_%s_$dt.bkp';
backup spfile tag QPAY_SPF_$dt format '/qpay_rmanbackup/qpay_spf_l1_%p_%s_$dt.bkp';
CROSSCHECK BACKUP;
CROSSCHECK ARCHIVELOG ALL;
delete noprompt archivelog until time 'sysdate -3';
DELETE NOPROMPT OBSOLETE RECOVERY WINDOW OF 7 DAYS;
release channel c1;
release channel c2;
}
!
echo "DCPDB LEVEL 1 BACKUP FINISHIED on  `date` " >>$LOG_FILE

exit 0

No comments:

Post a Comment