本文是一个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整合全局异常处理&SpringBoot整合定时任务Task&SpringBoot整合异步任务

    ============整合全局异常=========== 1.整合web访问的全局异常 如果不做全局异常处理直接访问如果报错,页面会报错500错误,对于界面的显示非常不友好,因此需要做处理. 全局异 ...

  2. APACHE - CXF 入门详解

    ref: https://www.cnblogs.com/hoojjack/p/6724659.html

  3. html5离线记事本

    离线记事本 这是一个笔记应用,不需要联网,也不需要数据库,可以直接把数据储存在本地.方便易用! ^_^ <!DOCTYPE html>  <html>  <head> ...

  4. Pytorch tutorial 之Datar Loading and Processing (1)

    引自Pytorch tutorial: Data Loading and Processing Tutorial 这节主要介绍数据的读入与处理. 数据描述:人脸姿态数据集.共有69张人脸,每张人脸都有 ...

  5. 3. SpringBoot ——自动配置原理浅析

    SpringBoot的功能之所以强大,离不开它的自动配置这一大特色.但估计很多人只是知其然而不知其所以然.下面本人对自动配置原理做一个分析: 在使用SpringBoot时我们通过引入不同的Starte ...

  6. dubbo源码分析4——SPI机制_ExtensionFactory类的作用

    ExtensionFactory的源码: @SPI public interface ExtensionFactory { /** * Get extension. * * @param type o ...

  7. DeprecationWarning: Calling an asynchronous function without callback is deprecated. - how to find where the “function:” is?

    I recently updated my node to 7.2.1 and noticed that there is a warning coming: (node:4346) Deprecat ...

  8. NodeJS基础教程

    关于 本书致力于教会你如何用Node.js来开发应用,过程中会传授你所有所需的“高级”JavaScript知识.本书绝不是一本“Hello World”的教程. 状态 你正在阅读的已经是本书的最终版. ...

  9. 【转】关于Log4j

    转自:http://www.open-open.com/lib/view/open1337754346355.html 原帖:http://blog.csdn.net/neareast/article ...

  10. 使用tomcat发布含有shtml文件的web程序

    平常都是使用html或jsp,当导入含有shtml的一个web项目时,向平常一样使用Jetty运行,访问到shtml文件时,直接在浏览器上显示出了源码. 查询,使用tomcat发布,修改tomcat的 ...