以前在博客裡面介紹了RMAN備份腳本一列分享,通過RMAN備份到本地路徑,然後通過FTP將備份文件上傳到FTP服務器。 下面簡單介紹另外一例RMAN備份解決方案,下面是我簡單畫的一個圖(很少畫圖,感覺有點粗制濫造)。
首先將數據庫備份到本地服務器的一個目錄下(目錄是按日期格式生成,本地備份保留周期視存儲情況而定.一般一天即可)。
然後將備份文件通過Symantec Backup Exec 2012 Agent 將本地備份上傳到磁帶設備(容災備份,磁帶備份保留90天)。
最後清理本地備份路徑下的備份。
如上所示,只有三個步驟,整體思路非常簡單,下面介紹一下實施的具體腳本
首先介紹一下備份腳本backup_db_xxxx.sh (注意xxx為數據庫實例名稱,腳本裡面很多xxx需要根據具體場景進行替換,例如實例名稱、郵件地址等)
1: #********************************************************************************
2: # FileName : backup_db_xxxx.sh
3: #********************************************************************************
4: # Author : Tommy
5: # CreateDate : 2012-07-18
6: # Description : this script is backup the oracle database by rman
7: #********************************************************************************
8: # Parameters : 參數說明
9: #********************************************************************************
10: # 此腳本無參數,直接調用即可
11: #********************************************************************************
12: # Modified Date Modified User Version Modified Reason
13: #********************************************************************************
14: # 2014-04-26 Kerry V1.0.1 腳本部分地方、調整腳本格式
15: #
16: #********************************************************************************
17:
18:
19:
20: #REM - USER DEFINED VARIABLES -
21: export DATESTAMP=`date '+%F'`
22:
23: #REM - Oracle specific settings: -
24: . /home/oracle/.bash_profile
25: export CATALOG=NOCATALOG
26:
27: #REM - Specify the Logfiles -
28: export BACKUP_FULL_LOG=/u04/backup/backuplogs/rman_backup_db_xxx_$DATESTAMP.log
29:
30: #REM - BACKUP SECTION -
31: echo $BACKUP_FULL_LOG
32: rman target / $CATALOG cmdfile=/u04/backup/scripts/backup_db_xxx.rcv log=$BACKUP_FULL_LOG
33:
34: EMAILTMP=/u04/backup/backuplogs/rman_backup_db_xxx_$DATESTAMP.TMP
35:
36: ######################## config email parameters ##########################
37: echo 'Content-Type: text/html' > $EMAILTMP
38: echo 'To: [email protected], [email protected],[email protected]' >> $EMAILTMP
39: echo 'Subject : Backup Status - xxxx(RMAN hot backup)' >> $EMAILTMP
40: echo '<pre> 41: ###########################################################################
42:
43: echo "=======================================================" >> $EMAILTMP
44: echo "================ Daily Backup for xxxx ================" >> $EMAILTMP
45: echo "=======================================================" >> $EMAILTMP
46: echo " " >> $EMAILTMP
47:
48: cat $BACKUP_FULL_LOG >> $EMAILTMP 2>&1
49: echo " " >> $EMAILTMP
50: echo "================ End of Rman Backup ==================" >> $EMAILTMP
51: echo "======================================================" >> $EMAILTMP
52:
53: /usr/sbin/sendmail -t -f "BackupAdmin" < $EMAILTMP
54: rm $EMAILTMPbackup_db_xxx.rcv 文件其實RMAN的命令文件(backup_db_xxxx.sh 裡面調用)。如下所示
1: run {
2: CONFIGURE RETENTION POLICY TO REDUNDANCY 2; # default
3: CONFIGURE BACKUP OPTIMIZATION ON;
4: CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
5: CONFIGURE CONTROLFILE AUTOBACKUP ON;
6: CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/u04/backup/backupsets/ora_cf%F';
7: CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default
8: CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
9: CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
10: CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT '/u04/backup/backupsets/ora_df%t_s%s_s%p';
11: CONFIGURE MAXSETSIZE TO UNLIMITED; # default
12: CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
13: CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
14: CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
15: sql 'alter system archive log current';
16: backup as compressed backupset database plus archivelog delete input;
17: copy current controlfile to '/u04/backup/backupsets/controlfile.copy';
18: }
19: exit
delete_obj_xxxx.sh 文件如下所示:
1: #*****************************************************************************************
2: # FileName : delete_obj_xxxx.sh
3: #*****************************************************************************************
4: # Author : Tommy
5: # CreateDate : 2012-07-18
6: # Description : this script is delete the obsolete object through rman
7: #*****************************************************************************************
8: # Parameters : 參數說明
9: #*****************************************************************************************
10: # 此腳本無參數,直接調用即可
11: #*****************************************************************************************
12: # Modified Date Modified User Version Modified Reason
13: #*****************************************************************************************
14: # 2014-04-26 Kerry V1.0.1 修改腳本部分地方、調整腳本格式
15: #
16: #
17: #
18: #*****************************************************************************************
19:
20:
21: #REM - USER DEFINED VARIABLES -
22: export DATESTAMP=`date '+%F'`
23:
24: #REM - Oracle specific settings: -
25: . /home/oracle/.bash_profile
26: export CATALOG=NOCATALOG
27:
28: #REM - Specified the logfiles -
29: export BACKUP_FULL_LOG=/u04/backup/backuplogs/rman_delete_ob_xxx_$DATESTAMP.log
30:
31: #REM - BACKUP SECTION -
32: echo $BACKUP_FULL_LOG
33: rman target / $CATALOG cmdfile=/u04/backup/scripts/delete_ob_xxx.rcv log=$BACKUP_FULL_LOG
/u04/backup/scripts/delete_ob_xxx.rcv文件為RMAN的cmdfile,如下所示
1: run {
2: CONFIGURE RETENTION POLICY TO REDUNDANCY 2; # default
3: CONFIGURE BACKUP OPTIMIZATION ON;
4: CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
5: CONFIGURE CONTROLFILE AUTOBACKUP ON;
6: CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/u04/backup/backupsets/ora_cf%F';
7: CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default
8: CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
9: CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
10: CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT '/u04/backup/backupsets/ora_df%t_s%s_s%p';
11: CONFIGURE MAXSETSIZE TO UNLIMITED; # default
12: CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
13: CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
14: CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
15: sql 'alter system archive log current';
16: delete obsolete;
17: }
然後再crontab作業裡面配置作業
15 00 * * * /u04/backup/scripts/backup_db_xxx.sh >/dev/null 2>&1
00 08 * * * /u04/backup/scripts/delete_ob_xxx.sh >/dev/null 2>&1
也許會有人問,不是還有Symantec Backup Exec Agent 將備份文件上帶嗎,其實關於這個,首先需要在Linux服務器安裝Symantec Backup Exec 2012 Agent,這個可以參考我博客Symantec Backup Exec 2012 Agent For Linux安裝。在配置文件指定Symantec Backup Exec Server,然後只需要在服務器設定一個作業定時備份文件即可。感覺沒有啥可以說的。