ORACLE使用資料泵定時執行備份

來源:互聯網
上載者:User

標籤: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使用資料泵定時執行備份

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.