Set retention policy to recovery window to 7 days.
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS;
Script for Backup Level 0
backup_0.sh
ORACLE_BASE=/oracle
ORACLE_HOME=$ORACLE_BASE/orahome
ORACLE_SID=orcl
export ORACLE_BASE ORACLE_HOME ORACLE_SID
export PATH=$PATH:/$ORACLE_HOME/bin
rman target=’system/bagbag’ cmdfile=’/oracle/rman_script/rman_backup0.cmd’ log=’/oracle/rman_script/backup-level0.log’
currentdate=`date ‘+%y%m%d_%H%M’`
file_name=hr_db_DC$currentdate.dmp
file_log=hr_db_DC$currentdate.log
expdp “‘/ as sysdba'” directory=bck_dir schemas=HR_DB LOGFILE=$file_log DUMPFILE=$file_name
compress /backup_oracle/$file_name
find /backup_oracle -name *.log -ctime +6 -exec rm -f {} \;
find /backup_oracle -name *.Z -ctime +6 -exec rm -f {} \;
exit
rman_backup0.cmd
connect catalog rman/pass;
crosscheck archivelog all;
crosscheck backup;
RUN {
allocate channel c1 device type disk;
allocate channel c2 device type disk;
allocate channel c3 device type disk;
allocate channel c4 device type disk;
SET CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO ‘/backupsystem/fra/orcl/autobackup/CL_SUNDAY_%F.bck’;
BACKUP tag=’SUNDAY_LVL0′ AS COMPRESSED backupset INCREMENTAL LEVEL 0 DATABASE plus archivelog;
delete noprompt archivelog until time ‘sysdate-1’ backed up 1 times to device type disk;
delete force noprompt obsolete;
SET CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO ‘%F’;
release channel c1;
release channel c2;
release channel c3;
release channel c4;
}
delete noprompt expired archivelog all;
delete noprompt expired backup;
Script for Backup Level 1
backup_1.sh
ORACLE_BASE=/oracle
ORACLE_HOME=$ORACLE_BASE/orahome
ORACLE_SID=orcl
export ORACLE_BASE ORACLE_HOME ORACLE_SID
export PATH=$PATH:/$ORACLE_HOME/bin
_dow=”$(date +’%A’)”
_logfile=”/oracle/rman_script/rman_backup${_dow}.log”
_cmdfile=”/oracle/rman_script/rman_backup${_dow}.cmd”
#echo $_cmdfile
#echo $_logfile
rman target=’system/bagbag’ cmdfile=$_cmdfile log=$_logfile
currentdate=`date ‘+%y%m%d_%H%M’`
file_name=hr_db_DC$currentdate.dmp
file_log=hr_db_DC$currentdate.log
expdp “‘/ as sysdba'” directory=hr_db_dir schemas=hr_db LOGFILE=$file_log DUMPFILE=$file_name
compress /backup_oracle/$file_name
find /backup_oracle -name *.log -ctime +6 -exec rm -f {} \;
find /backup_oracle -name *.Z -ctime +6 -exec rm -f {} \;
rman_backupMonday.cmd
connect catalog rman/pass;
RUN {
allocate channel D1 type disk;
SET CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO ‘/backupsystem/fra/orcl/autobackup/CL_MONDAYDAY_%F.bck’;
BACKUP TAG=’MONDAY_LVL1′ AS COMPRESSED backupset INCREMENTAL LEVEL 1 DATABASE plus archivelog;
delete noprompt archivelog until time ‘sysdate-1’ backed up 1 times to device type disk;
delete force noprompt obsolete;
SET CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO ‘%F’;
release channel D1;
}
what you have to do is replace rman_backupMonday.cmd with another day name.
example rman_backupTuesday.cmd …etc.
and replace tag name BACKUP TAG=’MONDAY_LVL1′ become BACKUP TAG=’TOESDAY_LVL1′
controlfile backup
SET CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO ‘/backupsystem/fra/orcl/autobackup/CL_MONDAYDAY_%F.bck’;
become
SET CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO ‘/backupsystem/fra/orcl/autobackup/CL_TUESDAYDAY_%F.bck’;