With 0112111 incremental backup strategy, 7 days a cycle
that is, Sunday level 0 backup, Week 1 2 4 5 6 with 2-level incremental backup, week 3 with 1-level incremental backup
Configure control file backup path
- RMAN > CONFIGURE controlfile autobackup FORMAT for DEVICE TYPE DISK to '/u01/backup/rmanbk/ccontrolfile_%f ';
Data Backup directory
- $ mkdir-p/U01/BACKUP/RMANBK
First set the number of days to expire to 7 days
- Rman> CONFIGURE RETENTION POLICY to RECOVERY windows of 7 days;
Start creating Level 0 1 Level 2 backup scripts below
Level 0 Backup Script
- Vim rman_bk_level0.sh
- ------Level 0 Backup----------------
- #! /bin/bash
- Export ORACLE_SID=ORCL
- Export nls_lang= ' American_america. ZHS16GBK '
- /u01/app/oracle/11.2.0/dbhome_1/bin/rman Target/<<eof
- run{
- Allocate channel D1 type disk;
- Allocate channel D2 type disk;
- Backup incremental Level 0 database format '/U01/BACKUP/RMANBK/LEVEL0_%D_%S_%P_%U.BKP ';
- SQL ' alter system archive log current ';
- Backup Archivelog All Delete input format '/U01/BACKUP/RMANBK/LOG_%D_%S_%P_U%.BKP ';
- }
- Crosscheck backup;
- Delete NoPrompt obsolete;
- Exit
- <<eof
- ------------------
Level 1 Backup Script
- Vim rman_bk_level1.sh
- ---------Level 1 Incremental backup---------------
- #! /bin/bash
- Export ORACLE_SID=ORCL
- Export nls_lang= ' American_america. ZHS16GBK '
- /u01/app/oracle/11.2.0/dbhome_1/bin/rman Target/<<eof
- run{
- Allocate channel D1 type disk;
- Allocate channel D2 type disk;
- Backup incremental Level 1 database format '/U01/BACKUP/RMANBK/LEVEL1_%D_%S_%P_%U.BKP ';
- SQL ' alter system archive log current ';
- Backup Archivelog All Delete input format '/U01/BACKUP/RMANBK/LOG_%D_%S_%P_U%.BKP ';
- }
- Crosscheck backup;
- Delete NoPrompt obsolete;
- Exit
- <<eof
Level 2 backup script
- Vim rman_bk_level2.sh
- ---------Level 2 Incremental backup---------------
- #! /bin/bash
- Export ORACLE_SID=ORCL
- Export nls_lang= ' American_america. ZHS16GBK '
- /u01/app/oracle/11.2.0/dbhome_1/bin/rman Target/<<eof
- run{
- Allocate channel D1 type disk;
- Allocate channel D2 type disk;
- Backup incremental Level 2 database format '/U01/BACKUP/RMANBK/LEVEL2_%D_%S_%P_%U.BKP ';
- SQL ' alter system archive log current ';
- Backup Archivelog All Delete input format '/U01/BACKUP/RMANBK/LOG_%D_%S_%P_U%.BKP ';
- }
- Crosscheck backup;
- Delete NoPrompt obsolete;
- Release D1;
- Exit
- <<eof
Add to Crontab
- Crontab-e
- -----------
- #周日0级备份
- XX * * 0/u01/backup_shell/rman_bk_level0.sh
- #周一, second, four or five, level 62 incremental backups
- XX * * 1,2,4,5,6/u01/backup_shell/rman_bk_level2.sh
- #周三1级增量备份
- XX * * 3/u01/backup_shell/rman_bk_level1.sh
Oracle Rman Incremental Backup script