oracle差异增量异地备份(Differential incremental and remote backup)

2021/7/24 2:18:20

本文主要是介绍oracle差异增量异地备份(Differential incremental and remote backup),对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

  1. 挂载nfs,并设置开机自动挂载。

2,编写level0备份脚本并chmod执行权限。

[oracle@oracle170 job]$ vim bak0.sh 
#~/.bashrc中有定义环境变量,脚本中就不需要重复定义。
export ORACLE_SID=OCR
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/12.2.0/db_1
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export NLS_DATE_FORMAT="YYYY-MM-DD HH24:MI:SS"
export TMP=/tmp
export TMPDIR=$TMP
export PATH=$ORACLE_HOME/bin:$ORACLE_HOME/OPatch:$HOME/.local/bin:$HOME/bin:$PATH
export EDITOR=vim
export TNS_ADMIN=$ORACLE_HOME/network/admin
export ORACLE_PATH=.:$ORACLE_BASE/dba_scripts/sql:$ORACLE_HOME/rdbms/admin
export SQLPATH=$ORACLE_HOME/sqlplus/admin
export NLS_LANG="SIMPLIFIED CHINESE_CHINA.AL32UTF8"
alias sqlplus='rlwrap sqlplus'
alias rman='rlwrap rman'
alias asmcmd='rlwrap asmcmd'
/u01/app/oracle/product/12.2.0/db_1/bin/rman target / log=/orabaskup/data/bak0.log append <<EOF
run{
    allocate channel c1 type disk;
    allocate channel c2 type disk;
    allocate channel c3 type disk;
    crosscheck archivelog all;#先crosscheck一下减少archivelog备份集大小
    delete noprompt expired archivelog all;
    backup incremental level 0 tag 'bak0' format '/orabaskup/data/bak0_%u_%d_%s' database ;
    sql 'alter system archive log current';#归档level0备份日志
    backup archivelog all tag='arch_bak' format '/orabaskup/data/archbak_%u_%d_%s' delete input;#控制文件和参数文件会自动备份。
    crosscheck backup;
    delete noprompt expired backup;
    delete noprompt obsolete;#删除废弃的备份。
    release channel c1;
    release channel c2;
    release channel c3;
    }
EOF

  

3,编写差异增量level1备份脚本并chmod执行权限。

[oracle@oracle170 job]$ vim bak1.sh 

export ORACLE_SID=OCR
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/12.2.0/db_1
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export NLS_DATE_FORMAT="YYYY-MM-DD HH24:MI:SS"
export TMP=/tmp
export TMPDIR=$TMP
export PATH=$ORACLE_HOME/bin:$ORACLE_HOME/OPatch:$HOME/.local/bin:$HOME/bin:$PATH
export EDITOR=vim
export TNS_ADMIN=$ORACLE_HOME/network/admin
export ORACLE_PATH=.:$ORACLE_BASE/dba_scripts/sql:$ORACLE_HOME/rdbms/admin
export SQLPATH=$ORACLE_HOME/sqlplus/admin
export NLS_LANG="SIMPLIFIED CHINESE_CHINA.AL32UTF8"
alias sqlplus='rlwrap sqlplus'
alias rman='rlwrap rman'
alias asmcmd='rlwrap asmcmd'
/u01/app/oracle/product/12.2.0/db_1/bin/rman target / log=/orabaskup/data/bak1.log append <<EOF
run{
    allocate channel c1 type disk;
    allocate channel c2 type disk;
    allocate channel c3 type disk;
    crosscheck archivelog all;
    delete noprompt expired archivelog all;
    backup incremental level 1 tag 'bak1' format '/orabaskup/data/bak1_%u_%d_%s' database ;
    sql 'alter system archive log current';
    backup archivelog all tag='arch_bak' format '/orabaskup/data/archbak_%u_%d_%s' delete input;
    crosscheck backup;
    delete noprompt expired backup;
    delete noprompt obsolete;
    release channel c1;
    release channel c2;
    release channel c3;
    }
EOF

  

4,oracle用户创建任务计划crontab

[oracle@oracle170 data]$ crontab -e

1 0 * * sat /orabaskup/job/bak0.sh#周六level0级备份
1 0 * * sun,mon,tue,wed,thu,fri /orabaskup/job/bak1.sh#其他level1级备份

 



这篇关于oracle差异增量异地备份(Differential incremental and remote backup)的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程