zoukankan      html  css  js  c++  java
  • 数据库备份脚本

    0级备份脚本(bak_lv_0)

    #!/bin/bash
    export PATH
    export TMP=/tmp
    export TMPDIR=$TMP
    export ORACLE_HOSTNAME=dbserver.localdomain
    export ORACLE_SID=datacenter
    export ORACLE_BASE=/arcerzhangoracle/app/oracle
    export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1
    export ORACLE_UNQNAME=datacenter
    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'
    
    
    /arcerzhangoracle/app/oracle/product/11.2.0/db_1/bin/rman <<EOF 
    connect target / 
    run{
        allocate channel c1 type disk;
        allocate channel c2 type disk;
        backup incremental level 0 database format '/arcerzhangoracle/Rmanbackup/level0_%d_%s_%p_%u_%T.bkp';
        sql 'alter system archive log current';
        backup archivelog all delete input format '/arcerzhangoracle/Rmanbackup/log_%d_%s_%p_%u_%T.bkp';
        release channel c1;
        release channel c2;
    }
    crosscheck backup;
    delete noprompt obsolete;
    exit; 
    EOF

     1级备份脚本(bak_lv_1)

    #!/bin/bash
    export PATH
    export TMP=/tmp
    export TMPDIR=$TMP
    export ORACLE_HOSTNAME=dbserver.localdomain
    export ORACLE_SID=datacenter
    export ORACLE_BASE=/arcerzhangoracle/app/oracle
    export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1
    export ORACLE_UNQNAME=datacenter
    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'
    
    
    /arcerzhangoracle/app/oracle/product/11.2.0/db_1/bin/rman <<EOF 
    connect target / 
    run{
        allocate channel c1 type disk;
        allocate channel c2 type disk;
        backup incremental level 1 database format '/arcerzhangoracle/Rmanbackup/level1_%d_%s_%p_%u_%T.bkp';
        sql 'alter system archive log current';
        backup archivelog all delete input format '/arcerzhangoracle/Rmanbackup/log_%d_%s_%p_%u_%T.bkp';
        release channel c1;
        release channel c2;
    }
    crosscheck backup;
    delete noprompt obsolete;
    exit; 
    EOF

     2级备份脚本(bak_lv_2)

    #!/bin/bash
    export PATH
    export TMP=/tmp
    export TMPDIR=$TMP
    export ORACLE_HOSTNAME=dbserver.localdomain
    export ORACLE_SID=datacenter
    export ORACLE_BASE=/arcerzhangoracle/app/oracle
    export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1
    export ORACLE_UNQNAME=datacenter
    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'
    
    
    /arcerzhangoracle/app/oracle/product/11.2.0/db_1/bin/rman <<EOF 
    connect target / 
    run{
        allocate channel c1 type disk;
        allocate channel c2 type disk;
        backup incremental level 2 database format '/arcerzhangoracle/Rmanbackup/level2_%d_%s_%p_%u_%T.bkp';
        sql 'alter system archive log current';
        backup archivelog all delete input format '/arcerzhangoracle/Rmanbackup/log_%d_%s_%p_%u_%T.bkp';
        release channel c1;
        release channel c2;
    }
    crosscheck backup;
    delete noprompt obsolete;
    exit; 
    EOF

     crontab中的定时任务脚本参考

    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
    00 01 * * * /arcerzhangoracle/auto_bak_exp/auto_bak_expdp.sh
  • 相关阅读:
    学习笔记-Python基础19-结构化文件存储-xml
    学习笔记-Python基础18-asyncio异步、aiohttp、concurrent并发
    学习笔记-Python基础17-迭代器、生成器、协成
    学习笔记-Python基础16-多进程
    学习笔记-Python基础16-多线程
    Java中BigDecimal的一个除法异常
    JUnit单元测试入门
    Location search 属性
    struts2表单提交的乱码的问题的解决
    出现java.lang.NoSuchFieldException resourceEntries错误的解决方法
  • 原文地址:https://www.cnblogs.com/arcer/p/3707620.html
Copyright © 2011-2022 走看看