==================  RMAN一周典型备份方案 ===============
 
1.星期天晚上      -level 0 backup (全备份)
2.星期一晚上      -level 2 backup 
3.星期二晚上      -level 2 backup 
4.星期三晚上      -level 1 backup 
5.星期四晚上      -level 2 backup 
6.星期五晚上      -level 2 backup 
7.星期六晚上      -level 2 backup 
 
 
如果星期二需要恢复的话,只需要1+2,
如果星期四需要恢复的话,只需要1+4,
如果星期五需要恢复的话,只需要1+4+5,
如果星期六需要恢复的话,只需要1+4+5+6.
 
自动备份:备份脚本+crontab
 bakl0
 bakl1
 bakl2
 
 
配置:
1: mkdir -p /u01/app/oracle/rmanbak/scripts/   (放备份脚本目录)
2: mkdir -p /u01/app/oracle/rmanbak/logs/      (放日志目录)
3: mkdir -p /u01/app/oracle/rmanbak/bak/       (放备份文件的目录)
4: crontab -e -u root
          30 23 * * 0 /u01/app/oracle/rmanbak/scripts/bakl0
          30 23 * * 0 /u01/app/oracle/rmanbak/scripts/bakl2
          30 23 * * 0 /u01/app/oracle/rmanbak/scripts/bakl2
          30 23 * * 0 /u01/app/oracle/rmanbak/scripts/bakl1
          30 23 * * 0 /u01/app/oracle/rmanbak/scripts/bakl2
          30 23 * * 0 /u01/app/oracle/rmanbak/scripts/bakl2
          30 23 * * 0 /u01/app/oracle/rmanbak/scripts/bakl2
 
5: service crond restart
 
6: 附件
   -------------------bakl0脚本------------------
      #!/bin/sh
      cd /u01/app/oracle/rmanbak/scripts
      su - oracle -c "rman target / msglog=/u01/app/oracle/rmanbak/logs/bakl0.log < /u01/app/oracle/rmanbak/scripts/bakl0.bak"
 
   -------------------bakl0.bak脚本--------------
   run {
    allocate channel c1 device type disk;
    allocate channel c2 device type disk;
    allocate channel c3 device type disk;
    allocate channel c4 device type disk;
    backup incremental level 0 format '/u01/app/oracle/rmanbak/bak/inc0_%u_%T' tag sunday_inc0 database;
    release channel c1;
    release channel c2;
    release channel c3;
    release channel c4;
   }
 
   -------------------bakl1脚本------------------
       #!/bin/sh
      cd /u01/app/oracle/rmanbak/scripts
      su - oracle -c "rman target / msglog=/u01/app/oracle/rmanbak/logs/bakl1.log < /u01/app/oracle/rmanbak/scripts/bakl1.bak"
 
   -------------------bakl1.bak脚本--------------
   run {
    allocate channel c1 device type disk;
    allocate channel c2 device type disk;
    allocate channel c3 device type disk;
    allocate channel c4 device type disk;
    backup incremental level 1 format '/u01/app/oracle/rmanbak/bak/inc1_%u_%T' tag inc1 database;
    release channel c1;
    release channel c2;
    release channel c3;
    release channel c4;
   }
   
   -------------------bakl2脚本------------------
        #!/bin/sh
        cd /u01/app/oracle/rmanbak/scripts
      su - oracle -c "rman target / msglog=/u01/app/oracle/rmanbak/logs/bakl2.log < /u01/app/oracle/rmanbak/scripts/bakl2.bak"
 
   -------------------bakl2.bak脚本--------------
   run {
    allocate channel c1 device type disk;
    allocate channel c2 device type disk;
    allocate channel c3 device type disk;
    allocate channel c4 device type disk;
    backup incremental level 2 format '/u01/app/oracle/rmanbak/bak/inc2_%u_%T' tag inc2 database;
    release channel c1;
    release channel c2;
    release channel c3;
    release channel c4;
   }