標籤:oracle 資料泵 aix contab
前言:隨著多個系統的逐步上線,作為營運人員,Database Backup顯得尤為重要,考慮到當前系統資源有限,資料庫處於非歸檔模式,使用資料泵每天進行全備,網上備份指令碼很多,本人也是參考網上一些指令碼分享並根據現有環境適當修改。
原文參考連結:http://www.osyunwei.com/archives/5960.html
作業系統環境:AIX 7.1.0.0
資料庫版本:Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
1.準備工作
資料庫建立directory
CREATE [OR REPLACE] DIRECTORY directory AS ‘/ogg/dumpfile‘;
建立備份路徑/ogg/dumpfile 修改所屬使用者和使用者組為oracle.oinstall
2.備份指令碼
res_zhejiang_bk.sh
#!/bin/bash
export ORACLE_BASE=/app/oracle
export ORACLE_SID=resdb1
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1
export ORACLE_TERM=xterm
export PATH=$PATH:$ORACLE_HOME/bin
export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
#以上代碼為oracle使用者的系統內容變數設定
#擷取系統當前日期時間
export BAKUPTIME=`date +%Y%m%d%H%M`
#設定刪除7天之前的備份檔案
export DELETE_DAYS=7
#指定directory路徑
export BAK_DIR=/ogg/dumpfile
#備份省份使用者
export BAK_USER=res_zhejiang
# 執行浙江存量備份
expdp system/systemres directory=DUMP_DIR schemas=${BAK_USER} dumpfile=${BAK_USER}_%U_${BAKUPTIME}.dmp logfile=${BAK_USER}_${BAKUPTIME}.log parallel=4 cluster=no
#壓縮備份檔案和記錄檔
tar -cvf ${BAK_DIR}/${BAK_USER}_${BAKUPTIME}.dmp.tar ${BAK_DIR}/${BAK_USER}_*.dmp ${BAK_DIR}/${BAK_USER}_*.log
#刪除7天前的備份檔案
find ${BAK_DIR}/* -type f -name "${BAK_USER}*.dmp" -exec rm {} \; #刪除備份檔案
find ${BAK_DIR}/* -type f -name "${BAK_USER}*.log" -exec rm {} \; #刪除記錄檔
3.指令碼賦予執行許可權
$chood a+x res_zhejiang_bk.sh
4.添加執行計畫
開啟執行計畫
crontab -e
crontab: you are not authorized to use cron. Sorry.
處理:
root使用者操作,添加oracle
vi /var/adm/cron/cron.allow
root
unionmon
oracle
使用crontab -e指定執行計畫
30 01 * * * /home/oracle/scripts/res_zhejiang_bk.sh
#查看執行計畫
crontab -l
5.驗證備份,查看備份日誌
本文出自 “Secdata Share Blog” 部落格,請務必保留此出處http://secdata.blog.51cto.com/11588948/1877664
ORACLE使用資料泵定時執行備份