oracle 備份指令碼

來源:互聯網
上載者:User

標籤:rds   generate   預設   nbsp   增量備份   oracle   info   database   備份指令碼   

   本文是一個shell指令碼。主要用於Oracle Database Backup。預設情況下,在周一晚上進行全備。其他時間進行累積增量備份。

  使用方法:

  假如指令碼儲存名為: 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) , 20160827                   ##: Modify Records:                                            ##: 1.                                                         ##: Thu May  4 19:42:54 CST 2017                               ##: halberd                                                    ##   add getopts . make the scripts more flexible              #################################################################: initial environmentsource ~/.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 variableswhile getopts p:l: optiondo    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        ;;    esacdone#:             initial other basic variablesmd=`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 "fiif [ -z "$LEVEL" ] ;then    if [ "$weekday" == 1 ] ;    then LEVEL=0    else LEVEL=1    fifi   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 commandsback_comm=‘run{     allocate channel c1 type disk;\nallocate channel c2 type disk;\nallocate channel c3 type disk;\nbackup as compressed backupset incremental level ‘"$LEVEL"‘ format ‘\‘"$BACK_FORMAT"\‘‘ database include current controlfile plus archivelog delete input;\nrelease channel c1;\nrelease channel c2;\nrelease channel c3;\n}\ncrosscheck archivelog all;\ndelete noprompt expired archivelog all;\nreport obsolete;\ndelete noprompt obsolete;\nexit‘#: execute rman backup echo -e $back_comm| rman target sys/oracle log "$BACK_PATH"/rman_"$md".logexit

 

oracle 備份指令碼

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.