本文是一个shell脚本。主要用于Oracle 数据库备份。默认情况下,在周一晚上进行全备。其他时间进行累积增量备份。

  使用方法:

  假如脚本保存名为: oracle_backup.sh

  使用方法为 oracle_backup.sh -p $ORACLE_DIRECTORY -L $BACKUP_LEVEL

  ORACLE_DIRECTORY 可从dba_directories 里查询所得。

  BACKUP_LEVEL: 0(全备) 1 增量。

#!/bin/sh
###############################################################
#: This script is used to backup Oracle database with RMAN. #
#: A full backup will be taken early moring on Monday . #
#: I recomment that the incremental backup should be taken on #
#: every day except Monday. #
#: Made by Halberd(Asiainfo-PMO) , #
#: Modify Records: #
#: . #
#: Thu May :: CST #
#: halberd #
# add getopts . make the scripts more flexible #
############################################################### #: initial environment source ~/.bash_profile #: judge if parameters are offered [ $# == ] && echo -e "Usage :: $0 -[pl]\n p --> backup path \n l --> backup level with 0(full) or 1(incremental) \n examples:: \n $0 -p /home/oracle -l 1" && exit #: variables setting
#: attach the arguments values to their variables
while getopts p:l: option
do
case "$option" in
p)
BACK_PATH="$OPTARG"
;;
l)
if
[ "$OPTARG" == ] ;
then
LEVEL=
elif
[ "$OPTARG" == ] ;
then
LEVEL=
else echo "Level 0 or 1 is recommended. You should better choose 0 for full backup or 1 for incremental backup"
exit
fi
;;
\?)
echo "Usage: [-p <PATH>] [-l]"
echo "-p : the path in which backup files will be allocated"
echo "-l : RMAN backup level"
exit
;;
esac done #: initial other basic variables md=`date +%m%d`
weekday=`date +%w` if [ -z "$BACK_PATH" ] ;
then
BACK_PATH="$ORACLE_HOME"/dbs
echo -e "WARNING :: The backup piecies will be stored in $ORACLE_HOME/dbs .\n "
fi if [ -z "$LEVEL" ] ;
then
if [ "$weekday" == ] ;
then LEVEL=
else LEVEL=
fi
fi BACK_FORMAT="$BACK_PATH"/db"$LEVEL"'_%d_%T_%u' echo "BACKUP_PATH: $BACK_PATH"
echo "BACKUP_LEVEL:" "$LEVEL"
echo "BACKUP_FORMAT: $BACK_FORMAT" #: generate the rman commands
back_comm='
run{
allocate channel c1 type disk;\n
allocate channel c2 type disk;\n
allocate channel c3 type disk;\n
backup as compressed backupset incremental level '"$LEVEL"' format '\'"$BACK_FORMAT"\'' database include current controlfile plus archivelog delete input;\n
release channel c1;\n
release channel c2;\n
release channel c3;\n
}\n
crosscheck archivelog all;\n
delete noprompt expired archivelog all;\n
report obsolete;\n
delete noprompt obsolete;\n
exit
' #: execute rman backup
echo -e $back_comm| rman target sys/oracle log "$BACK_PATH"/rman_"$md".log
exit

oracle 备份脚本的更多相关文章

  1. 5、Oracle备份(oracle备份脚本配置)

    1.1 Oracle数据库备份 1.1.1 链接Oracle介质管理库 请在数据库节点上操作. [oracle@db01/usr/openv/netbackup/bin]$ ./oracle_link ...

  2. oracle备份脚本

    利用EXP导出全库,必须用SYSTEM或者DBA用户来导出. 具体脚本实现如下 全库导出(fullbackup): #!/bin/bash bname=`date +%Y%m%d` cd /backu ...

  3. Oracle自动备份脚本(网上找到的资料)

    废话不多说了,直接给大家贴代码了,具体代码如下所示: ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 ...

  4. Windows环境下Oracle数据库的自动备份脚本

    批处理文件(.bat) @echo off echo ================================================ echo  Windows环境下Oracle数据 ...

  5. oracle expdp自动备份脚本

    windows: @echo off echo ================================================ echo Windows环境下Oracle数据库的自动 ...

  6. Windows:Oracle 11g 备份脚本

    @echo off echo ================================================ echo Windows环境下Oracle数据库的自动备份脚本 echo ...

  7. Oracle自动备份脚本的实现

    问题描述: Oracle自动备份脚本的实现. 错误提示1: Message file RMAN.msb not found Verify that Oracle_HOME is set properl ...

  8. Oracle数据库的自动备份脚本

    @echo off echo ================================================ echo Windows环境下Oracle数据库的自动备份脚本 echo ...

  9. Windows环境下Oracle数据库的自动备份脚本自动删除30天前的备份

    @echo off echo ================================================ echo Windows环境下Oracle数据库的自动备份脚本 echo ...

随机推荐

  1. Springboot 配置 ssl 实现HTTPS 请求 & Tomcat配置SSL支持https请求

    SSL(Secure Sockets Layer 安全套接层),及其继任者传输层安全(Transport Layer Security,TLS)是为网络通信提供安全及数据完整性的一种安全协议.TLS与 ...

  2. TextView 文字拼接

    //引用文字 String testStr = (getResources().getString(R.string.test_str,"<font color='#ff0000'&g ...

  3. CMakeLists 链接库相关指令

    set(LSTAR_DIR "$ENV{HOME}/LStar_build") include_directories(${LSTAR_DIR}) LINK_DIRECTORIES ...

  4. pymongo加索引以及查看索引例子

    # -*- coding: utf-8 -*- # @Time : 2018/12/28 10:01 AM # @Author : cxa import pymongo db_configs = { ...

  5. 前端 -----js 定时器

    定时器   在js中的定时器分两种:1.setTimeout() 2.setInterval() 1.setTimeOut() 只在指定时间后执行一次 /定时器 异步运行 function hello ...

  6. 【原创】Thinking in BigData (1)大数据简介

    提到大数据,就不得不提到Hadoop,提到Hadoop,就不得不提到Google公布的3篇研究论文:GFS.MapReduce.BigTable,Google确实是一家伟大的公司,开启了全球的大数据时 ...

  7. layui框架中关于table方法级渲染和自动化渲染之间的区别简单介绍

    方法级渲染: <table class="layui-hide" id="LAY_table_user" lay-filter="user&qu ...

  8. Solidity(address的四个方法)

    address的四个方法send,call,callcode,delegatecall 例子:发送以太币的send方法//下面是send方法,涉及到以太币的情况可能用到payable,senddemo ...

  9. lua 复制table

    cocos2d-lua提供了复制方法clone(),源码如下: function clone(object) local lookup_table = {} local function _copy( ...

  10. 洛谷P4827 [国家集训队] Crash 的文明世界 [斯特林数,组合数,DP]

    传送门 思路 又见到这个\(k\)次方啦!按照套路,我们将它搞成斯特林数: \[ ans_x=\sum_{i=0}^k i!S(k,i)\sum_y {dis(x,y) \choose i} \] 前 ...