This is a production database's rman backup shell script, divided into zero-level backup and one-level differential cumulative backup, zero-level backup once a week, and other one-level differential cumulative backup.
1. Zero-level backup shell script:
- #! /Bin/sh
- #### 2011.6.27 ####
- # Level = 0 #
- Export TMP =/tmp
- Export TMPDIR =/tmp
- Export Oracle_BASE =/opt/oracleonder
- Export ORACLE_HOME = $ ORACLE_BASE/product/10.2.0/db_1
- Export ORACLE_SID = onder
- Export PATH = $ PATH: $ ORACLE_HOME/bin:
- Export LD_LIBRARY_PATH = $ ORACLE_HOME/lib:/usr/lib
- Export BAKFILE =/opt/bak/bak0.log
- Find/opt/bak/archbak-mtime + 365-name "arch * .tar.bz2"-exec rm-rf {}\## because only backup of level 0 is performed every week, archive logs cannot be automatically deleted (only when you run the command # Full backup, archive backup is set to invalid). Therefore, a command is provided to delete the archive log backups outside the storage policy.
- Rman nocatalog target/msglog $ BAKFILE <EOF
- Run {
- Configure controlfile autobackup on;
- Configure controlfile autobackup format for device type disk to '/opt/bak/conf_0000f_0000t.tar.bz2 ';
- Configure retention policy to redundancy 20;
- Configure device type disk parallelism 1 backup type to compressed backupset;
- Report obsolete;
- Delete noprompt obsolete;
- Crosscheck backup;
- Delete noprompt expired backup;
- Backup incremental level = 0 database format'/opt/bak/bak_effect_0000u_0000t_0000d.tar.bz2 'plus archivelog format'/opt/bak/archbak/arch_0000u_0000s.tar.bz2 ';
- DELETE noprompt archivelog all completed before 'sysdate-30 ';
- Crosscheck archivelog all; # Check the archived log records that do not exist in the system. Although the preceding command deletes the archived logs for more than 30 days, the related records # record still exists.
- Delete noprompt expired archivelog all; ### the noprompt parameter is required to be deleted directly without confirmation.
- }
- EOF