Oracle rman 备份脚本
采用RMAN差异增量备份模式,周期为7天,每周一进行0级增量,周二至星期天进行1级差异增量,
始终保留30天恢复窗口,利用crontab在每天03:30进行
CRONTAB 0级增量
- 30 03 * * 1 /backup/scripts/0_backup.sh 2>/backup/logs/2.log
SHELL脚本0级增量
- #!/bin/sh
- ORACLE_SID=test
- ORACLE_BASE=/app/oracle
- ORACLE_HOME=/app/oracle/product/10.2.0/db_1
- PATH=/app/oracle/product/10.2.0/db_1/bin:$PATH
- export ORACLE_SID ORACLE_BASE ORACLE_HOME PATH
- /app/oracle/product/10.2.0/db_1/bin/rman target / cmdfile=/backup/scripts/0_backup.rman msglog=/backup/logs/`date +%Y%m%d_%w_0.log`
RMAN脚本0级增量
- RUN{
- CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 30 DAYS;
- CONFIGURE CONTROLFILE AUTOBACKUP ON;
- CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/backup/backupsets/%F_CNT_0';
- ALLOCATE CHANNEL C1 TYPE DISK;
- ALLOCATE CHANNEL C2 TYPE DISK;
- ALLOCATE CHANNEL C3 TYPE DISK;
- ALLOCATE CHANNEL C4 TYPE DISK;
- BACKUP INCREMENTAL LEVEL 0 FORMAT '/backup/backupsets/%T_%s_%p_DAT_0' DATABASE SKIP INACCESSIBLE
- PLUS ARCHIVELOG FORMAT '/backup/backupsets/%T_%s_%p_ARC_0' DELETE ALL INPUT;
- RELEASE CHANNEL C1;
- RELEASE CHANNEL C2;
- RELEASE CHANNEL C3;
- RELEASE CHANNEL C4;
- }
- ALLOCATE CHANNEL FOR MAINTENANCE DEVICE TYPE DISK;
- CROSSCHECK BACKUPSET;
- DELETE NOPROMPT EXPIRED BACKUP;
- DELETE NOPROMPT OBSOLETE;
- RELEASE CHANNEL;
CRONTAB 1级增量
30 03 * * 2,3,4,5,6,7 /backup/scripts/1_backup.sh 2>/backup/logs/2.log
SHELL脚本1级增量
- #!/bin/sh
- ORACLE_SID=test
- ORACLE_BASE=/app/oracle
- ORACLE_HOME=/app/oracle/product/10.2.0/db_1
- PATH=/app/oracle/product/10.2.0/db_1/bin:$PATH
- export ORACLE_SID ORACLE_BASE ORACLE_HOME PATH
- /app/oracle/product/10.2.0/db_1/bin/rman target / cmdfile=/backup/scripts/1_backup.rman msglog=/backup/logs/`date +%Y%m%d_%w_1.log`
RMAN脚本1级增量
- RUN{
- CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 30 DAYS;
- CONFIGURE CONTROLFILE AUTOBACKUP ON;
- CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/backup/backupsets/%F_CNT_1';
- ALLOCATE CHANNEL C1 TYPE DISK;
- ALLOCATE CHANNEL C2 TYPE DISK;
- ALLOCATE CHANNEL C3 TYPE DISK;
- ALLOCATE CHANNEL C4 TYPE DISK;
- BACKUP INCREMENTAL LEVEL 1 FORMAT '/backup/backupsets/%T_%s_%p_DAT_1' DATABASE SKIP INACCESSIBLE
- PLUS ARCHIVELOG FORMAT '/backup/backupsets/%T_%s_%p_ARC_1' DELETE ALL INPUT;
- RELEASE CHANNEL C1;
- RELEASE CHANNEL C2;
- RELEASE CHANNEL C3;
- RELEASE CHANNEL C4;
- }
- ALLOCATE CHANNEL FOR MAINTENANCE DEVICE TYPE DISK;
- CROSSCHECK BACKUPSET;
- DELETE NOPROMPT EXPIRED BACKUP;
- DELETE NOPROMPT OBSOLETE;
- RELEASE CHANNEL;
目录 返回
首页