RUN {
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW
OF 30 DAYS;
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR
DEVICE TYPE DISK TO '/home/oracle/oracle10g/backup/%F';
ALLOCATE CHANNEL C1 DEVICE TYPE DISK FORMAT
'/home/oracle/oracle10g/backup/bak_level0_%T_%U';
BACKUP INCREMENTAL LEVEL=0 DATABASE SKIP
INACCESSIBLE PLUS ARCHIVELOG FILESPERSET 20 DELETE ALL INPUT;
RELEASE CHANNEL C1;
}
ALLOCATE CHANNEL FOR MAINTENANCE DEVICE TYPE
DISK;
CROSSCHECK BACKUPSET;
DELETE NOPROMPT OBSOLETE;
2)1级备份脚本
脚本名称:backup_ora_level1.sh
存放目录:/home/oracle
脚本内容:
#!/bin/bash
export
PATH=$PATH:$ORACLE_HOME/bin
export TIME=`date +%Y%m%d%H%M`
rman TARGET
/ log /home/oracle/rmanlog/${TIME}.log
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW
OF 30 DAYS;
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR
DEVICE TYPE DISK TO '/home/oracle/oracle10g/backup/%F';
ALLOCATE CHANNEL C1 DEVICE TYPE DISK FORMAT
'/home/oracle/oracle10g/backup/bak_level1_%T_%U';
BACKUP INCREMENTAL LEVEL=1 DATABASE SKIP
INACCESSIBLE PLUS ARCHIVELOG FILESPERSET 20 DELETE ALL INPUT;
RELEASE CHANNEL C1;
}
ALLOCATE CHANNEL FOR MAINTENANCE DEVICE TYPE
DISK;
CROSSCHECK BACKUPSET;
DELETE NOPROMPT OBSOLETE;
3)定时执行脚本
利用crontab在每周一二三四五六的凌晨一点执行1级备份,每周日的凌晨一点执行0级备份。具体命令为:
~> crontab -e
0 1 * * 0 /home/oracle/backup_ora_level0.sh
0 1 * * 1,2,3,4,5,6
/home/oracle/backup_ora_level1.sh
DELETE ALL INPUTDELETE ALL INPUTDELETE ALL INPUT