本文是一个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. python,关于这个里边的私有方法(private)、保护方法(protected)、公开方法(public)

    __foo__: 定义的是特殊方法,一般是系统定义名字 ,类似 __init__() 之类的. _foo: 以单下划线开头的表示的是 protected 类型的变量,即保护类型只能允许其本身与子类进行 ...

  2. 绕过PALOALTO TRAPS EDR解决方案

    0x1 技术点 PaloAlto Traps(EDR解决方案)基于行为封锁和标记许多黑客工具. 0x2 绕过方法 最简单的解决方案就是禁用内置实用程序,即; Cytool.Cytool是一个集成命令行 ...

  3. V4L2开发要点【转】

    转自:https://blog.csdn.net/mr_raptor/article/details/7441141 首先来看 Read/Write ,如果 VIDIOC_QUERYCAP 调用返回的 ...

  4. docker里面运行jenkins详解

    需求:将jenkins运行在docker中 思路:1.安装docker,并启动docker 服务            2.下载jenkins的docker镜像,然后运行. 前提知识:1.dockde ...

  5. linux mysql 定时备份 使用crontab

    第一步:在服务器上配置备份目录代码: mkdir /var/lib/mysqlbackup cd /var/lib/mysqlbackup 第二步:编写备份脚本代码:  vi dbbackup.sh ...

  6. Python2018-列表的相关操作

    列表中存放的数据是可以进行修改的,比如"增"."删"."改" .“查” "增"-----append, extend, ...

  7. page_cleaner: 1000ms intended loop took 4724ms. The settings might not be optimal. (flushed=1037, during the time.)

    2018-07-09T14:28:56.853600Z 0 [Note] InnoDB: page_cleaner: 1000ms intended loop took 4724ms. The set ...

  8. word发布博客

    无向图双连通部件(双连通分量) 关节点和桥边的定义: 双连通部件的性质   每一个双连通部件应该包含至少两个顶点,除非整个无向图只包含一个顶点   如果两个双连通部件包含同一个顶点,那么这个共有的顶点 ...

  9. linux杀死僵尸进程

    用下面的命令找出僵死进程 ps -A -o stat,ppid,pid,cmd | grep -e '^[Zz]' 命令注解: -A 参数列出所有进程 -o 自定义输出字段 我们设定显示字段为 sta ...

  10. spring、springMVC、mybatis配置文件

    一.jdbc.properties 文件: driver=com.mysql.jdbc.Driverurl=jdbc:mysql://192.168.31.xxx:3306/abc?useUnicod ...