Oracle RMAN 备份一例

Oracle RMAN备份一例:

Solaris 10 + Oracle 11.2.0.3

Shell:csh,安装有bash,脚本调用bash

备份策略:周日0级备份,周一~周六1级备份,每6小时备份归档日志,每天清理历史文件夹.

--0级备份脚本:

#!/bin/bash
#db0 level backup
foldername=`date +%Y%m%d`
cd /oradata1/backup
if [ -d $foldername ]
then
        echo    'go on'
else
        echo    'need mkdir'
        mkdir $foldername
fi

export ORACLE_BASE=/opt/app/oracle/
export ORACLE_HOME=/opt/app/oracle/product/11.2.0/dbhome_1/
export ORACLE_SID=SHIRNOP
export NLS_LANG="simplified chinese_china.ZHS16GBK"
export NLS_DATE_FORMAT="YYYY-MM-DD HH24:Mi:SS"
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$ORACLE_HOME/lib32
export PATH=/bin:/usr/bin:/usr/ucb:/etc:$ORACLE_HOME/bin:.

rman target /  log=/oradata1/backup/$foldername/full_LOG.log << RMAN_BACKUP
run{
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS;
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/oradata1/backup/$foldername/controlfile%F';
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 tag 'db0' database format '/oradata1/backup/$foldername/db0_%d_%T_%s' include current controlfile;
delete noprompt obsolete;
release channel c1;
release channel c2;
release channel c3;
release channel c4;
}
RMAN_BACKUP

--1级备份脚本:

#!/bin/bash
#db1 level backup
foldername=`date +%Y%m%d`
cd /oradata1/backup
if [ -d $foldername ]
then
        echo    'go on'
else
        echo    'need mkdir'
        mkdir $foldername
fi

export ORACLE_BASE=/opt/app/oracle/
export ORACLE_HOME=/opt/app/oracle/product/11.2.0/dbhome_1/
export ORACLE_SID=SHIRNOP
export NLS_LANG="simplified chinese_china.ZHS16GBK"
export NLS_DATE_FORMAT="YYYY-MM-DD HH24:Mi:SS"
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$ORACLE_HOME/lib32
export PATH=/bin:/usr/bin:/usr/ucb:/etc:$ORACLE_HOME/bin:.

rman target /  log=/oradata1/backup/$foldername/incr_LOG.log << RMAN_BACKUP
run{
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS;
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/oradata1/backup/$foldername/controlfile%F';
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 tag 'db1' database format '/oradata1/backup/$foldername/db1_%d_%T_%s' include current controlfile;
delete noprompt obsolete;
release channel c1;
release channel c2;
release channel c3;
release channel c4;
}
RMAN_BACKUP

--归档备份

#!/bin/bash
#arch backup
foldername=`date +%Y%m%d`
cd /oradata1/backup
if [ -d $foldername ]
then
        echo    'go on'
else
        echo    'need mkdir'
        mkdir $foldername
fi

export ORACLE_BASE=/opt/app/oracle/
export ORACLE_HOME=/opt/app/oracle/product/11.2.0/dbhome_1/
export ORACLE_SID=SHIRNOP
export NLS_LANG="simplified chinese_china.ZHS16GBK"
export NLS_DATE_FORMAT="YYYY-MM-DD HH24:Mi:SS"
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$ORACLE_HOME/lib32
export PATH=/bin:/usr/bin:/usr/ucb:/etc:$ORACLE_HOME/bin:.

rman target /  log=/oradata1/backup/$foldername/arch_LOG.log << RMAN_BACKUP
run{
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS;
allocate channel c1 device type disk;
allocate channel c2 device type disk;
sql 'alter system archive log current';
backup archivelog all delete input format '/oradata1/backup/$foldername/arch_%d_%T_%s';
release channel c1;
release channel c2;
}
crosscheck archivelog all;
delete expired archivelog all;
RMAN_BACKUP

--系统级别删除过期备份的空文件夹

#!/bin/bash
#del old folders
cd /oradata1/backup
find . -mtime +10 | xargs rm -rf

--crontab调度 crontab -l

0 1 * * 0 /oradata1/backupsh/db0_backup.rman > /dev/null 2&>1#
0 1 * * 1-6 /oradata1/backupsh/db1_backup.rman > /dev/null 2&>1#
0 6,12,18 * * * /oradata1/backupsh/arch_backup.rman > /dev/null 2&>1#
0 3 * * * /oradata1/backupsh/del_old.sh > /dev/null 2&>1#

本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。

我来说两句

0 条评论
登录 后参与评论

相关文章

  • Linux平台 Oracle 12cR2 RAC安装Part1:准备工作

    本文安装环境:RHEL 6.5 + Oracle 12.2.0.1 GI & RAC

    Alfred Zhao
  • DG环境数据库RMAN备份策略制定 全库备份 归档备份 删除历史文件夹 删除归档

    Alfred Zhao
  • Linux平台 Oracle 18c RAC安装Part1

    Linux平台 Oracle 18c RAC安装指导: Part1:Linux平台 Oracle 18c RAC安装Part1:准备工作 Part2:Lin...

    Alfred Zhao
  • Linux下安装Oracle的过程和涉及的知识点-系列4

    如果本地有现成的相关包,可以直接使用rpm安装。rpm rpm包名,但有时会出现它需要其它包的支持,这时若需要忽略此提示,强行安装,执行rpm -i --for...

    bisal
  • 牛逼! IDEA 2020 要本土化,真的是全中文了!

    上个月 JetBrains 发布了 IntelliJ 平台 2020 年路线图,现在作为 2020 年规划中的另一部分,JetBrains 又发布了基于 Int...

    搜云库技术团队
  • IntelliJ 发布 2020 RoadMap,中文版终于要来了?

    来源 | https://www.oschina.net/news/112937/intellij-based-ide-features-roadmap-for...

    Java技术江湖
  • 如何处理Eclipse错误消息 The declared package does not match the expected package

    我从github下载了一个开源项目后,导入到自己Eclipse之后,遇到了这个烦人的错误消息: The declared package “com.sap.s...

    Jerry Wang
  • 基于 IntelliJ 的 IDE 功能路线图出来了,终于要支持中文!

    上个月 JetBrains 发布了 IntelliJ 平台 2020 年路线图,现在作为 2020 年规划中的另一部分,JetBrains 又发布了基于 Int...

    芋道源码
  • AI生成的假新闻难以识别,那就用神经网络来对抗吧

    论文地址:https://arxiv.org/pdf/1905.12616.pdf

    机器之心
  • 玩转C语言链表-链表各类操作详解

    链表是一种常见的重要的数据结构。它是动态地进行存储分配的一种结构。它可以根据需要开辟内存单元。链表有一个“头指针”变量,以head表示,它存放一个地址。该地址指...

    用户6754675

扫码关注云+社区

领取腾讯云代金券