RedHat Linux下使用Crontab實現Oracle 10g 定時備份

來源:互聯網
上載者:User

RedHat Linux下使用Crontab實現Oracle 10g 定時備份(包含SFTP下載說明)。

這是說的定時備份是熱備份,也就是寫shell指令碼,這是的文法是oracle10g的,9i稍微修改(用exp文法)

定時備份後,可以用用戶端機器自動下載,用sftp用戶端,設定成自動下載,如沒有可以去網上找sftp的實現,java有開源的。

1.建立shell 備份指令檔

#!/bin/sh

#oracle command

expcmd="/opt/ora10/product/10g/bin/"

#bakup dir 這個備份目錄是用expdp  需要先建立,10g裡面有的,自己可以去查 create directory 命令

dbbakdir="dbbakdir"

#bakup file name

filebak1="$(date +%Y%m%d%H%M%S)dbbak1.dmp"

#bakup db log

dboplog="db1.log"

#table name 這裡是以備份某個表做的,其他自己可以參考expdp 文法

tablenames ="xxxtablename"

./expdp username/password@dbname directory=$dbbakdir dumpfile=$filebak1  logfile=$dboplog   filesize=4G tables=$tablenames

這個儲存為/oralce/shelltest.sh ,賦執行許可權 chmod +x ,需要用oracle安裝使用者如useroracle,不能用root使用者。

2.添加crontab任務

用oracle安裝使用者如useroracle執行下面命令

#crontab -e

30 01 * * * /oralce/shelltest.sh

上面設定的是,每天淩晨1點半執行,具體文法,看 crontab 格式

設定之後,可以用crontab -l 命令查看

 

聯繫我們

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