shell指令碼利用rman實現自動備份資料庫

2021-09-11 10:39:13 字數 1974 閱讀 5347

b     backup path 

l     backup level with 0(full) or 1(incremental) 

s     the user sys pawword 

不利用引數則採用預設,預設備份路徑為:$oracle_base/flash_recovery_area/orcl/backupset  。備份預設級別則為:週日全備,其他增量備份。預設sys密碼為:123456(密碼可在指令碼修改)。自動刪除過期備份。採用自動分配通道進行備份。

#!/bin/bash

#this script is used to backup oracle database with rman

#last time: 2019.2.27

[ $# == 0 ] && echo -e " b backup path \n l backup level with 0(full) or 1(incremental) \n s the user sys pawword "

#: variables setting

while getopts b:l:s: option

do case "$option" in

b)back_path="$optarg"

;;l)

if[ "$optarg" == 0 ] ;

then

level=0

elif

[ "$optarg" == 1 ] ;

then

level=1

else echo "this script provide only level "0" or "1" backup"

exit 1

fi;;

s)passwd="$optarg"

;;\?)

echo "-b : the path in which backup files"

echo "-l : rman backup level"

echo "-s : the user sys pawword"

exit 1

;;esac

done

weekday='date +%w'

if [ -z "$back_path" ] ;

then

back_path="$oracle_base"/flash_recovery_area/orcl/backupset

echo -e "warning :: the backup piecies will be stored in $oracle_base/flash_recovery_area/orcl/backupset\n "

fiif [ -z "$level" ] ;

then

if [ "$weekday" == 1 ] ;

then level=0

else level=1

fifiif [ -z "$passwd" ] ;

then

passwd="123456"

fiback_format="$back_path"/db"$level"'_%d_%t_%u'

echo "backup_path: $back_path"

echo "backup_level:" "$level"

echo "backup_format: $back_format"

back_cmd='

runcrosscheck archivelog all;\n

delete noprompt expired archivelog all;\n

report obsolete;\n

delete noprompt obsolete;\n

exit

'#excute rman cmd

echo -e $back_cmd|rman target sys/$passwd

exit

shell指令碼利用expect實現scp免密傳輸

shell指令碼實現scp傳輸 命令解釋 c 表示可以在命令列下執行except指令碼 spawn 命令啟用乙個unix程式來互動,就是在之後要執行的命令 expect aaa 表示程式在等待這個aaa的字串 send 向程式傳送字串,expect和send經常是成對出現的,比如當expect aa...

shell指令碼利用sed命令分割檔案

前幾天有個需求,網路模組5秒定時傳回領區資訊並寫入檔案,需求為5分鐘後讀取檔案,提取每次傳回的領區資訊中的earfcn和rsrp等,每次傳回的資訊以 為分隔符 檔案格式如下 領區資訊.領區資訊.領區資訊.領區資訊.領區資訊.提取資訊前要先把每5秒傳回的資訊分割,然後再提取,所以就寫了一下的指令碼來提...

指令碼 利用svn版本號動態生成version h

bin bash big version 1.0 out file uiversion.h svn ip 192.168.0.117 echo ifndef ui version h out file echo define ui version h out file xversion svn in...