Oracle Rman Backup Example: Solaris + Oracle 11.2.0.3SHELL:CSH Backup strategy: Sunday Level 0 Backup, Monday ~ Weekly level 61 backup, Backup archive log every 6 hours, clean up the History folder every day.--Level 0 backup script:
#!/bin/csh#db0 level backupfoldername= ' Date +%y%m%d ' cd/oradata1/backupif [-D $foldername]then echo ' Go on ' els e Echo ' need mkdir ' mkdir $foldernamefiset oracle_sid shirnopset oracle_base/opt/app/oracle/set oracle_h Ome/opt/app/oracle/product/11.2.0/dbhome_1/set Nls_lang "Simplified Chinese_china. ZHS16GBK "Set Nls_date_format" Yyyy-mm-dd HH24:Mi:SS "set path/bin:/usr/bin:/usr/local/bin:/usr/ucb:/usr/bin/csh:/ Etc:/opt/app/oracle/product/11.2.0/dbhome_1//bin:.rman target/log=/oradata1/backup/$foldername/full_log_%u.log << rman_backuprun{configure RETENTION POLICY to RECOVERY windows of 8 days; CONFIGURE Controlfile autobackup on; CONFIGURE controlfile autobackup FORMAT for DEVICE TYPE DISK to '/oradata1/backup/$foldername/controlfile%f '; allocate Channel C1 device type Disk;allocate Channel C2 device type Disk;backup incremental level 0 tag ' db0 ' database format '/or adata1/backup/$foldername/db0_%d_%t_%s ' include current Controlfile;delete noprompt ObsoleTe;release channel c1;release channel C2;} Rman_backup
--Level 1 backup script:
#!/bin/csh#db1 level backupfoldername= ' Date +%y%m%d ' cd/oradata1/backupif [-D $foldername]then echo ' Go on ' els e Echo ' need mkdir ' mkdir $foldernamefiset oracle_sid shirnopset oracle_base/opt/app/oracle/set oracle_h Ome/opt/app/oracle/product/11.2.0/dbhome_1/set Nls_lang "Simplified Chinese_china. ZHS16GBK "Set Nls_date_format" Yyyy-mm-dd HH24:Mi:SS "set path/bin:/usr/bin:/usr/local/bin:/usr/ucb:/usr/bin/csh:/ Etc:/opt/app/oracle/product/11.2.0/dbhome_1//bin:.rman target/log=/oradata1/backup/$foldername/incr_log_%u.log << rman_backuprun{configure RETENTION POLICY to RECOVERY windows of 8 days; CONFIGURE Controlfile autobackup on; CONFIGURE controlfile autobackup FORMAT for DEVICE TYPE DISK to '/oradata1/backup/$foldername/controlfile%f '; allocate Channel C1 device type Disk;allocate Channel C2 device type Disk;backup incremental Level 1 tag ' DB1 ' database format '/or adata1/backup/$foldername/db1_%d_%t_%s ' include current Controlfile;delete noprompt ObsoleTe;release channel c1;release channel C2;} Rman_backup
--Archive backup
#!/bin/csh#arch backupfoldername= ' date +%y%m%d ' cd/oradata1/backupif [-D $ FolderName]then Echo ' go on ' else echo ' need mkdir ' mkdir $foldernamefiset Oracle_base/opt/app /oracle/set oracle_home/opt/app/oracle/product/11.2.0/dbhome_1/set oracle_sid SHIRNOPset NLS_LANG "simplified Chinese_china. ZHS16GBK "Set Nls_date_format" Yyyy-mm-dd HH24:Mi:SS "set path/bin:/usr/bin:/usr/local/bin:/usr/ucb:/usr/bin/csh:/ Etc:/opt/app/oracle/product/11.2.0/dbhome_1//bin:.rman target/log=/oradata1/backup/$foldername/arch_log_%u.log << rman_backuprun{configure RETENTION POLICY to RECOVERY WINDOW of 8 days;allocate channel C1 device type Disk;alloc ATE channel C2 device type Disk;sql ' alter system archive log current ', backup archivelog all delete input format '/oradata 1/backup/$foldername/arch_%d_%t_%s '; release channel c1;release channel C2;} Crosscheck archivelog All;delete expired archivelog all; Rman_backup
--System level Delete empty folders for expired backups
#!/bin/bash#del old Folderscd/oradata1/backupfind. -mtime +10 | Xargs RM-RF
--crontab Scheduling
Crontab-l
0 1 * * 0/oradata1/backupsh/db0_backup.rman >/dev/null 2&>1#0 1 * * 1-6/oradata1/backupsh/db1_backup.rman ; /dev/null 2&>1#0 6,12,18 * * */oradata1/backupsh/arch_backup.rman >/dev/null 2&>1#0 3 * * */oradata1/b ackupsh/del_old.sh >/dev/null 2&>1#