I am using linux on this backup procedure. I will create a weekly full backup (incremental level 0) and daily backup (incremental level 1). Change file location as needed.
First step is login as oracle user.
Next create a script for weekly backup and save as weekly_full.rman
Copy this script below:
#*** Weekly RMAN Script weekly_full.rman
CONNECT TARGET /
#*** Weekly full controlfile backup
BACKUP AS COPY
DEVICE TYPE DISK
TAG = 'WEEKLY_CONTROLFILE'
FORMAT '/oracle/ITB/db/apps_st/rman_backup/weekly_controlfile_%d_t%t_s%s_p%p'
CURRENT CONTROLFILE;
#*** Weekly full spfile backup
BACKUP AS COPY
DEVICE TYPE DISK
TAG = 'WEEKLY_SPFILE'
FORMAT '/oracle/ITB/db/apps_st/rman_backup/weekly_spfile_%d_t%t_s%s_p%p'
SPFILE;
#*** Weekly full database plus archivelog backup
BACKUP CHECK LOGICAL
AS COMPRESSED BACKUPSET
INCREMENTAL LEVEL = 0
DEVICE TYPE DISK
TAG = 'WEEKLY_DATABASE'
FORMAT '/oracle/ITB/db/apps_st/rman_backup/weekly_database_%d_t%t_s%s_p%p'
DATABASE;
#*** Weekly full archivelog backup
change archivelog all validate;
sql 'ALTER SYSTEM ARCHIVE LOG CURRENT';
BACKUP CHECK LOGICAL
AS COMPRESSED BACKUPSET
INCREMENTAL LEVEL = 0
DEVICE TYPE DISK
TAG = 'WEEKLY_ARCHIVELOG'
FORMAT '/oracle/ITB/db/apps_st/rman_backup/weekly_archivelog_%d_t%t_s%s_p%p'
ARCHIVELOG FROM TIME 'SYSDATE-7';
#*** Remove old backups and archivelogs
#DELETE BACKUP COMPLETED BEFORE 'SYSDATE-10' DEVICE TYPE DISK;
#DELETE NOPROMPT ARCHIVELOG UNTIL TIME 'SYSDATE-30';
#*** Maintenance steps
CROSSCHECK COPY;
CROSSCHECK BACKUP;
CROSSCHECK ARCHIVELOG ALL;
REPORT OBSOLETE;
DELETE NOPROMPT OBSOLETE;
DELETE NOPROMPT EXPIRED COPY;
DELETE NOPROMPT EXPIRED BACKUP;
DELETE NOPROMPT EXPIRED ARCHIVELOG ALL;
EXIT;
##***End of weekly_full.rman
Then create a script file for daily backup and save as daily_incremental.rman
This is the script:
#*** Daily RMAN Script daily_incremental.rman
CONNECT TARGET /
#*** Daily full controlfile backup
BACKUP AS COPY
DEVICE TYPE DISK
TAG = 'DAILY_CONTROLFILE'
FORMAT '/oracle/ITB/db/apps_st/rman_backup/daily_controlfile_%d_t%t_s%s_p%p'
CURRENT CONTROLFILE;
#*** Daily full spfile backup
BACKUP AS COPY
DEVICE TYPE DISK
TAG = 'DAILY_SPFILE'
FORMAT '/oracle/ITB/db/apps_st/rman_backup/daily_spfile_%d_t%t_s%s_p%p'
SPFILE;
#*** Daily full database backup
BACKUP CHECK LOGICAL
AS COMPRESSED BACKUPSET
INCREMENTAL LEVEL = 1
DEVICE TYPE DISK
TAG = 'DAILY_INCREMENTAL_DATABASE'
FORMAT '/oracle/ITB/db/apps_st/rman_backup/daily_incremental_database_%d_t%t_s%s_p%p'
DATABASE;
#*** Daily full archivelog backup
change archivelog all validate;
sql 'ALTER SYSTEM ARCHIVE LOG CURRENT';
BACKUP CHECK LOGICAL
AS COMPRESSED BACKUPSET
INCREMENTAL LEVEL = 1
DEVICE TYPE DISK
TAG = 'DAILY_INCREMENTAL_ARCHIVELOG'
FORMAT '/oracle/ITB/db/apps_st/rman_backup/daily_incremental_archivelog_%d_t%t_s%s_p%p'
ARCHIVELOG FROM TIME 'SYSDATE-1';
#*** Maintenance steps
REPORT OBSOLETE;
DELETE NOPROMPT OBSOLETE;
DELETE NOPROMPT EXPIRED COPY;
DELETE NOPROMPT EXPIRED BACKUP;
DELETE NOPROMPT EXPIRED ARCHIVELOG ALL;
EXIT;
##***End of daily_incremental.rman
Create a shell script to run rman script above.
For weekly, create a file named weekly.sh containing this script:
#! /bin/sh
source /oracle/ITB/db/tech_st/10.2.0/ITB_oracle.env
rman @/home/oracle/weekly_full.rman LOG /home/oracle/weekly_full.rman.log
For daily, create a file named daily.sh containing this script:
#! /bin/sh
source /oracle/ITB/db/tech_st/10.2.0/ITB_oracle.env
rman @/home/oracle/daily_incremental.rman LOG /home/oracle/daily_incremental.rman.log
Then login as root. Open /etc/crontab and add these lines to the end of file.
30 21 * * 0 oracle /home/oracle/weekly.sh &> /home/oracle/weekly.log
30 21 * * 1-6 oracle /home/oracle/daily.sh &> /home/oracle/daily.log
The daily_incremental.rman script will be executed automaticaly on Monday to Saturday 21:30. The weekly_full.rman script will be executed automaticaly on Sunday 21:30.
No comments:
Post a Comment