Linux에서 전체 RMAN 증분 백업 셸 스크립트
13136 단어 셸 스크립트
1 #!/bin/bash
2 #######################################################################
3 #
4 # :
5 # 0 ,
6 # , ,
7 # , , , ,
8 # 00 4 * * 0 /u01/app/oracle/rman_bak/scripts/rman_bak.sh 0
9 # 00 4 * * 1,4 /u01/app/oracle/rman_bak/scripts/rman_bak.sh 1
10 # 00 4 * * 2,3,5,6 /u01/app/oracle/rman_bak/scripts/rman_bak.sh 2
11 #
12 #######################################################################
13 # :
14 #set env
15 #
16 export ORACLE_BASE=/u01/app/oracle
17 export ORACLE_HOME=$ORACLE_BASE/db10g
18 export ORACLE_SID=emar
19 export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
20 export PATH=$ORACLE_HOME/bin:$PATH
21
22 DATE=`date +%w`
23 DATE_2=`date +%Y%m%d`
24 BACKUP_PATH=/u01/app/oracle/rman_bak
25 # :
26 LEVEL=$@
27 TARGET_SID=emar
28 RMAN_SID=emar.emar
29 BIN=/u01/app/oracle/db10g/bin
30
31 # Delete the data backuped last time
32 #rm -rf $BACKUP_PATH/data/$DATE/*
33
34 if [ $# != 1 ]; then
35 echo "usage: rman_bak.sh n
36 where n is the rman backup level(0,1,2 is permitted)."
37 exit 1
38 fi
39
40 if [ $@ -ne 0 -a $@ -ne 1 -a $@ -ne 2 ]; then
41 echo "usage: rman_bak.sh n
42 where n is the rman backup level(Only 0,1,2 is permitted)."
43 exit 2
44 fi
45
46 echo "-----------------------------start-----------------------------";date
47
48 #0 , rman here document
49 if [ $LEVEL = 0 ]; then
50
51 $BIN/rman log $BACKUP_PATH/log/level.$TARGET_SID.$LEVEL.$DATE_2.log <<EOF
52 connect target sys/sys202;
53 # catalog
54 connect catalog rman/rman@$RMAN_SID;
55 resync catalog;
56 run{
57 allocate channel c1 type disk ;
58 #
59 crosscheck backupset of archivelog all ;
60 # 7 ;format
61 backup filesperset 3 format '$BACKUP_PATH/data/$DATE/arch.%d.live.$LEVEL.%t'(archivelog from time 'sysdate-7' all delete input) ;
62 # expired ,noprompt
63 delete noprompt expired backupset of archivelog all ;
64 release channel c1 ;
65 }
66
67 run{
68 allocate channel c2 type disk ;
69 crosscheck backupset of database ;
70 backup incremental level $LEVEL filesperset 3 format '$BACKUP_PATH/data/$DATE/data.%d.live.$LEVEL.%t'(database include current controlfile) ;
71 --sql 'alter system archive log current';
72 delete noprompt expired backupset of database ;
73 delete noprompt obsolete ;
74 release channel c2 ;
75 }
76 exit;
77 EOF
78
79 # 1,2
80 else
81 $BIN/rman log $BACKUP_PATH/log/level.$TARGET_SID.$LEVEL.$DATE_2.log <<EOF
82 connect target sys/sys202;
83 connect catalog rman/rman@$RMAN_SID;
84 resync catalog;
85 run{
86 allocate channel c1 type disk ;
87 --sql 'alter system archive log current';
88 crosscheck backupset of archivelog all ;
89 backup filesperset 3 format '$BACKUP_PATH/data/$DATE/arch.%d.live.$LEVEL.%t' (archivelog from time 'sysdate-1' all) ;
90 delete noprompt expired backupset of archivelog all ;
91 release channel c1 ;
92 }
93
94 run{
95 allocate channel c2 type disk ;
96 crosscheck backupset of database ;
97 backup incremental level $LEVEL filesperset 3 format '$BACKUP_PATH/data/$DATE/data.%d.live.$LEVEL.%t' (database include current controlfile) ;
98 --sql 'alter system archive log current';
99 delete noprompt expired backupset of database ;
100 delete noprompt obsolete ;
101 release channel c2 ;
102 }
103
104 exit;
105 EOF
106 fi
107
108 $BIN/exp rman/rman@$RMAN_SID file=$BACKUP_PATH/data/$DATE/live.rman.$DATE_2.dmp log=$BACKUP_PATH/log/$RMAN_SID.rman.$DATE_2.log
109
110 echo "------------------------------end------------------------------";date
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
git-자동화 스크립트우선 우리는https://github.com/github에서 GitHub 창고를 신청했습니다.(과정은 소개하지 않겠습니다) 이제 우리는git의 자동 스크롤 스크립트를 작성합니다. - 버전 번호를 통해 코드를 스크롤합...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.