当前位置:Gxlcms > 数据库问题 > oracle 备份脚本

oracle 备份脚本

时间:2021-07-01 10:21:17 帮助过:9人阅读

############################################################### #: 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) , 20160827 # #: Modify Records: # #: 1. # #: Thu May 4 19:42:54 CST 2017 # #: halberd # # add getopts . make the scripts more flexible # ############################################################### #: initial environment source ~/.bash_profile #: judge if parameters are offered [ $# == 0 ] && 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 1 #: 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" == 0 ] ; then LEVEL=0 elif [ "$OPTARG" == 1 ] ; then LEVEL=1 else echo "Level 0 or 1 is recommended. You should better choose 0 for full backup or 1 for incremental backup" exit 1 fi ;; \?) echo "Usage: [-p <PATH>] [-l]" echo "-p : the path in which backup files will be allocated" echo "-l : RMAN backup level" exit 1 ;; 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" == 1 ] ; then LEVEL=0 else LEVEL=1 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 备份脚本

标签:rds   generate   默认   nbsp   增量备份   oracle   info   database   备份脚本   

人气教程排行