• RMAN备份:一个典型的增量备份案例如下:


    一个典型的增量备份案例如下:

    1. 星期天晚上   -levle 0 backup performed
    2. 星期一晚上   -levle 2 backup performed
    3. 星期二晚上   -levle 2 backup performed
    4. 星期三晚上   -levle 1 backup performed
    5. 星期四晚上   -levle 2 backup performed
    6. 星期五晚上   -levle 2 backup performed
    7. 星期六晚上   -levle 2 backup performed
    • 自动备份:备份脚本 +crontab

    baklv0

    #!/bin/bash
    export PATH
    export TMP=/tmp
    export TMPDIR=$TMP
    export ORACLE_HOSTNAME=11203ora.localdomain
    export ORACLE_SID=testdb
    export ORACLE_BASE=/u01/app/oracle
    export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1
    export ORACLE_UNQNAME=testdb
    export TNS_ADMIN=$ORACLE_HOME/network/admin
    export ORACLE_TERM=xterm
    export PATH=/usr/sbin:$PATH
    export PATH=$ORACLE_HOME/bin:$PATH
    export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
    export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
    export EDITOR=vi
    export LANG=en_US
    export NLS_LANG=american_america.AL32UTF8
    export NLS_DATE_FORMAT='yyyy/mm/dd hh24:mi:ss'
    /u01/app/oracle/product/11.2.0/db_1/bin/rman <<EOF
    connect target / catalog rman/rman
    run{
            allocate channel c1 type disk;
            allocate channel c2 type disk;
            backup incremental level 0 database format '/home/oracle/RmanBackup/level0_%d_%s_%p_%u_%T.bkp';
            sql 'alter system archive log current';
            backup archivelog all delete input format '/home/oracle/RmanBackup/log_%d_%s_%p_%u_%T.bkp';
            release channel c1;
            release channel c2;
    }
    crosscheck backup;
    delete noprompt obsolete;
    exit;
    EOF
    脚本内容

    baklv1

    #!/bin/bash
    export PATH
    export TMP=/tmp
    export TMPDIR=$TMP
    export ORACLE_HOSTNAME=11203ora.localdomain
    export ORACLE_SID=testdb
    export ORACLE_BASE=/u01/app/oracle
    export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1
    export ORACLE_UNQNAME=testdb
    export TNS_ADMIN=$ORACLE_HOME/network/admin
    export ORACLE_TERM=xterm
    export PATH=/usr/sbin:$PATH
    export PATH=$ORACLE_HOME/bin:$PATH
    export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
    export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
    export EDITOR=vi
    export LANG=en_US
    export NLS_LANG=american_america.AL32UTF8
    export NLS_DATE_FORMAT='yyyy/mm/dd hh24:mi:ss'
    /u01/app/oracle/product/11.2.0/db_1/bin/rman <<EOF
    connect target / catalog rman/rman
    run{
            allocate channel c1 type disk;
            allocate channel c2 type disk;
            backup incremental level 1 database format '/home/oracle/RmanBackup/level1_%d_%s_%p_%u_%T.bkp';
            sql 'alter system archive log current';
            backup archivelog all delete input format '/home/oracle/RmanBackup/log_%d_%s_%p_%u_%T.bkp';
            release channel c1;
            release channel c2;
    }
    crosscheck backup;
    delete noprompt obsolete;
    exit;
    EOF
    脚本内容

    baklv2

    #!/bin/bash
    export PATH
    export TMP=/tmp
    export TMPDIR=$TMP
    export ORACLE_HOSTNAME=11203ora.localdomain
    export ORACLE_SID=testdb
    export ORACLE_BASE=/u01/app/oracle
    export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1
    export ORACLE_UNQNAME=testdb
    export TNS_ADMIN=$ORACLE_HOME/network/admin
    export ORACLE_TERM=xterm
    export PATH=/usr/sbin:$PATH
    export PATH=$ORACLE_HOME/bin:$PATH
    export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
    export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
    export EDITOR=vi
    export LANG=en_US
    export NLS_LANG=american_america.AL32UTF8
    export NLS_DATE_FORMAT='yyyy/mm/dd hh24:mi:ss'
    /u01/app/oracle/product/11.2.0/db_1/bin/rman <<EOF
    connect target / catalog rman/rman
    run{
            allocate channel c1 type disk;
            allocate channel c2 type disk;
            backup incremental level 2 database format '/home/oracle/RmanBackup/level2_%d_%s_%p_%u_%T.bkp';
            sql 'alter system archive log current';
            backup archivelog all delete input format '/home/oracle/RmanBackup/log_%d_%s_%p_%u_%T.bkp';
            release channel c1;
            release channel c2;
    }
    crosscheck backup;
    delete noprompt obsolete;
    exit;
    EOF
    脚本内容
    • 执行脚本:

    rman target / msglog=/home/oracle/RmanBackup/bak_lv_0.log cmdfile=/home/oracle/BackupScripts/bak_lv_0

    rman target / msglog=/home/oracle/RmanBackup/bak_lv_1.log cmdfile=/home/oracle/BackupScripts/bak_lv_1

    rman target / msglog=/home/oracle/RmanBackup/bak_lv_2.log cmdfile=/home/oracle/BackupScripts/bak_lv_2

    • crontab -e oracle
    00      03      *        *       0              /home/oracle/BackupScripts/bak_lv_0 >> /home/oracle/RmanBackup/bak_lv_0.log
    00      03      *        *       1,2,4,5,6      /home/oracle/BackupScripts/bak_lv_2 >> /home/oracle/RmanBackup/bak_lv_2.log
    00      03      *        *       3              /home/oracle/BackupScripts/bak_lv_1 >> /home/oracle/RmanBackup/bak_lv_1.log
    View Code

    注意:

      1、上述自动执行脚本需要在root用户下执行,执行命令:crontab -e -u oracle,编辑完成,保存退出;

      2、重新启动一下crontab命令即可:service crond restart

    RMAN> list backupset summary;
    
    
    List of Backups
    ===============
    Key     TY LV S Device Type Completion Time     #Pieces #Copies Compressed Tag
    ------- -- -- - ----------- ------------------- ------- ------- ---------- ---
    186     B  0  A DISK        2013/07/12 23:52:56 1       1       NO         MONDAY_INC0
    187     B  0  A DISK        2013/07/12 23:53:07 1       1       NO         MONDAY_INC0
    188     B  1  A DISK        2013/07/12 23:56:57 1       1       NO         MONDAY_INC1
    189     B  1  A DISK        2013/07/12 23:57:06 1       1       NO         MONDAY_INC1
    190     B  2  A DISK        2013/07/12 23:59:25 1       1       NO         MONDAY_INC2
    191     B  2  A DISK        2013/07/12 23:59:36 1       1       NO         MONDAY_INC2
    192     B  A  A DISK        2013/07/13 00:31:10 1       1       YES        TAG20130713T003102
    193     B  F  A DISK        2013/07/13 00:32:10 1       1       YES        TAG20130713T003118
    194     B  F  A DISK        2013/07/13 00:32:15 1       1       YES        TAG20130713T003118
    195     B  A  A DISK        2013/07/13 00:32:16 1       1       YES        TAG20130713T003216
    196     B  F  A DISK        2013/07/13 00:32:18 1       1       NO         TAG20130713T003217
    197     B  1  A DISK        2013/07/13 00:54:33 1       1       NO         TAG20130713T005408
    198     B  1  A DISK        2013/07/13 00:54:34 1       1       NO         TAG20130713T005408
    199     B  F  A DISK        2013/07/13 00:54:44 1       1       NO         TAG20130713T005444
    200     B  A  A DISK        2013/07/13 00:54:46 1       1       NO         TAG20130713T005446
    201     B  A  A DISK        2013/07/13 00:54:46 1       1       NO         TAG20130713T005446
    202     B  F  A DISK        2013/07/13 00:54:47 1       1       NO         TAG20130713T005447
    203     B  0  A DISK        2013/07/13 01:02:51 1       1       NO         TAG20130713T010217
    204     B  0  A DISK        2013/07/13 01:02:52 1       1       NO         TAG20130713T010217
    205     B  F  A DISK        2013/07/13 01:03:03 1       1       NO         TAG20130713T010302
    206     B  A  A DISK        2013/07/13 01:03:04 1       1       NO         TAG20130713T010304
    207     B  A  A DISK        2013/07/13 01:03:04 1       1       NO         TAG20130713T010304
    208     B  F  A DISK        2013/07/13 01:03:06 1       1       NO         TAG20130713T010305
    209     B  2  A DISK        2013/07/13 01:09:46 1       1       NO         TAG20130713T010924
    210     B  2  A DISK        2013/07/13 01:09:47 1       1       NO         TAG20130713T010924
    211     B  F  A DISK        2013/07/13 01:09:50 1       1       NO         TAG20130713T010949
    212     B  A  A DISK        2013/07/13 01:09:51 1       1       NO         TAG20130713T010951
    213     B  A  A DISK        2013/07/13 01:09:51 1       1       NO         TAG20130713T010951
    214     B  F  A DISK        2013/07/13 01:09:52 1       1       NO         TAG20130713T010952
    215     B  1  A DISK        2013/07/13 01:11:18 1       1       NO         TAG20130713T011055
    216     B  1  A DISK        2013/07/13 01:11:19 1       1       NO         TAG20130713T011055
    217     B  F  A DISK        2013/07/13 01:11:21 1       1       NO         TAG20130713T011121
    218     B  A  A DISK        2013/07/13 01:11:22 1       1       NO         TAG20130713T011122
    219     B  A  A DISK        2013/07/13 01:11:22 1       1       NO         TAG20130713T011122
    220     B  F  A DISK        2013/07/13 01:11:24 1       1       NO         TAG20130713T011123
    221     B  0  A DISK        2013/07/13 01:36:15 1       1       NO         TAG20130713T013542
    222     B  0  A DISK        2013/07/13 01:36:16 1       1       NO         TAG20130713T013542
    223     B  F  A DISK        2013/07/13 01:36:18 1       1       NO         TAG20130713T013618
    224     B  A  A DISK        2013/07/13 01:36:20 1       1       NO         TAG20130713T013619
    225     B  A  A DISK        2013/07/13 01:36:20 1       1       NO         TAG20130713T013619
    226     B  F  A DISK        2013/07/13 01:36:21 1       1       NO         TAG20130713T013621
    227     B  0  A DISK        2013/07/13 03:10:38 1       1       NO         TAG20130713T031002
    228     B  0  A DISK        2013/07/13 03:10:39 1       1       NO         TAG20130713T031002
    229     B  F  A DISK        2013/07/13 03:10:48 1       1       NO         TAG20130713T031048
    230     B  A  A DISK        2013/07/13 03:10:50 1       1       NO         TAG20130713T031050
    231     B  A  A DISK        2013/07/13 03:10:50 1       1       NO         TAG20130713T031050
    232     B  F  A DISK        2013/07/13 03:10:51 1       1       NO         TAG20130713T031051
    233     B  1  A DISK        2013/07/13 03:21:27 1       1       NO         TAG20130713T032103
    234     B  1  A DISK        2013/07/13 03:21:28 1       1       NO         TAG20130713T032103
    235     B  F  A DISK        2013/07/13 03:21:28 1       1       NO         TAG20130713T032128
    236     B  A  A DISK        2013/07/13 03:21:30 1       1       NO         TAG20130713T032129
    237     B  A  A DISK        2013/07/13 03:21:30 1       1       NO         TAG20130713T032129
    238     B  F  A DISK        2013/07/13 03:21:31 1       1       NO         TAG20130713T032131
    239     B  1  A DISK        2013/07/13 03:31:27 1       1       NO         TAG20130713T033102
    240     B  1  A DISK        2013/07/13 03:31:28 1       1       NO         TAG20130713T033102
    241     B  F  A DISK        2013/07/13 03:31:38 1       1       NO         TAG20130713T033138
    242     B  A  A DISK        2013/07/13 03:31:39 1       1       NO         TAG20130713T033139
    243     B  A  A DISK        2013/07/13 03:31:39 1       1       NO         TAG20130713T033139
    244     B  F  A DISK        2013/07/13 03:31:41 1       1       NO         TAG20130713T033140
    245     B  2  A DISK        2013/07/13 03:41:26 1       1       NO         TAG20130713T034102
    246     B  2  A DISK        2013/07/13 03:41:28 1       1       NO         TAG20130713T034102
    247     B  F  A DISK        2013/07/13 03:41:28 1       1       NO         TAG20130713T034128
    248     B  A  A DISK        2013/07/13 03:41:30 1       1       NO         TAG20130713T034129
    249     B  A  A DISK        2013/07/13 03:41:30 1       1       NO         TAG20130713T034129
    250     B  F  A DISK        2013/07/13 03:41:31 1       1       NO         TAG20130713T034131
    251     B  2  A DISK        2013/07/13 03:51:27 1       1       NO         TAG20130713T035103
    252     B  2  A DISK        2013/07/13 03:51:28 1       1       NO         TAG20130713T035103
    253     B  F  A DISK        2013/07/13 03:51:29 1       1       NO         TAG20130713T035128
    254     B  A  A DISK        2013/07/13 03:51:30 1       1       NO         TAG20130713T035130
    255     B  A  A DISK        2013/07/13 03:51:30 1       1       NO         TAG20130713T035130
    256     B  F  A DISK        2013/07/13 03:51:31 1       1       NO         TAG20130713T035131
    257     B  0  A DISK        2013/07/13 04:01:37 1       1       NO         TAG20130713T040103
    258     B  0  A DISK        2013/07/13 04:01:38 1       1       NO         TAG20130713T040103
    259     B  F  A DISK        2013/07/13 04:01:39 1       1       NO         TAG20130713T040139
    260     B  A  A DISK        2013/07/13 04:01:40 1       1       NO         TAG20130713T040140
    261     B  A  A DISK        2013/07/13 04:01:40 1       1       NO         TAG20130713T040140
    262     B  F  A DISK        2013/07/13 04:01:42 1       1       NO         TAG20130713T040141
    263     B  0  A DISK        2013/07/13 04:11:37 1       1       NO         TAG20130713T041103
    264     B  0  A DISK        2013/07/13 04:11:38 1       1       NO         TAG20130713T041103
    265     B  F  A DISK        2013/07/13 04:11:49 1       1       NO         TAG20130713T041148
    266     B  A  A DISK        2013/07/13 04:11:50 1       1       NO         TAG20130713T041150
    267     B  A  A DISK        2013/07/13 04:11:50 1       1       NO         TAG20130713T041150
    268     B  F  A DISK        2013/07/13 04:11:51 1       1       NO         TAG20130713T041151
    269     B  1  A DISK        2013/07/13 04:21:28 1       1       NO         TAG20130713T042103
    270     B  1  A DISK        2013/07/13 04:21:28 1       1       NO         TAG20130713T042103
    271     B  F  A DISK        2013/07/13 04:21:39 1       1       NO         TAG20130713T042138
    272     B  A  A DISK        2013/07/13 04:21:40 1       1       NO         TAG20130713T042140
    273     B  A  A DISK        2013/07/13 04:21:40 1       1       NO         TAG20130713T042140
    274     B  F  A DISK        2013/07/13 04:21:41 1       1       NO         TAG20130713T042141
    275     B  1  A DISK        2013/07/13 04:31:27 1       1       NO         TAG20130713T043103
    276     B  1  A DISK        2013/07/13 04:31:28 1       1       NO         TAG20130713T043103
    277     B  F  A DISK        2013/07/13 04:31:29 1       1       NO         TAG20130713T043128
    278     B  A  A DISK        2013/07/13 04:31:30 1       1       NO         TAG20130713T043130
    279     B  A  A DISK        2013/07/13 04:31:30 1       1       NO         TAG20130713T043130
    280     B  F  A DISK        2013/07/13 04:31:31 1       1       NO         TAG20130713T043131
    281     B  2  A DISK        2013/07/13 04:41:28 1       1       NO         TAG20130713T044103
    282     B  2  A DISK        2013/07/13 04:41:30 1       1       NO         TAG20130713T044103
    283     B  F  A DISK        2013/07/13 04:41:39 1       1       NO         TAG20130713T044139
    284     B  A  A DISK        2013/07/13 04:41:40 1       1       NO         TAG20130713T044140
    285     B  A  A DISK        2013/07/13 04:41:40 1       1       NO         TAG20130713T044140
    286     B  F  A DISK        2013/07/13 04:41:41 1       1       NO         TAG20130713T044140
    287     B  2  A DISK        2013/07/13 04:51:28 1       1       NO         TAG20130713T045103
    288     B  2  A DISK        2013/07/13 04:51:29 1       1       NO         TAG20130713T045103
    289     B  F  A DISK        2013/07/13 04:51:39 1       1       NO         TAG20130713T045138
    290     B  A  A DISK        2013/07/13 04:51:40 1       1       NO         TAG20130713T045140
    291     B  A  A DISK        2013/07/13 04:51:40 1       1       NO         TAG20130713T045140
    292     B  F  A DISK        2013/07/13 04:51:40 1       1       NO         TAG20130713T045140
    293     B  0  A DISK        2013/07/13 05:01:36 1       1       NO         TAG20130713T050102
    294     B  0  A DISK        2013/07/13 05:01:38 1       1       NO         TAG20130713T050102
    295     B  F  A DISK        2013/07/13 05:01:38 1       1       NO         TAG20130713T050138
    296     B  A  A DISK        2013/07/13 05:01:40 1       1       NO         TAG20130713T050139
    297     B  A  A DISK        2013/07/13 05:01:40 1       1       NO         TAG20130713T050139
    298     B  F  A DISK        2013/07/13 05:01:41 1       1       NO         TAG20130713T050141
    660     B  F  A DISK        2013/07/13 07:44:00 1       1       NO         TAG20130713T074400
    670     B  F  A DISK        2013/07/13 07:44:42 1       1       NO         TAG20130713T074406
    685     B  F  A DISK        2013/07/13 07:44:53 1       1       NO         TAG20130713T074453
    
    RMAN> 
    list backupset summary
  • 相关阅读:
    HDU1255覆盖的面积
    B. An express train to reveries
    Long Long Message(后缀数组)
    Longest Common Substring(最长公共子序列)
    最长上升子序列(NlogN)总结
    bzoj 1500 维修数列
    HDU 6357 Hills And Valleys
    牛客暑假多校第六场 I Team Rocket
    HDU 6346 整数规划 二分图匹配最优解
    牛客暑假多校第五场 I vcd
  • 原文地址:https://www.cnblogs.com/arcer/p/3182237.html
Copyright © 2020-2023  润新知