Oracle expdp/impdp匯入匯出備份資料庫指令碼

urgel_babay發表於2016-02-29
2014.12.01

當oracle在非歸檔情況執行時,又需要備份資料庫,那麼exp/expdp作為匯出,imp/impdp作為匯入時不錯的選擇。
下面是一個簡單的全庫匯出的指令碼
[oracle@BIDB scripts]$ cat full_bak.sh 
#!/bin/bash
. /home/oracle/.bash_profile
cd /orabak/dbbak

echo "#######################################################" >> /orabak/log/full.txt
echo "starting delete logfile at `date`" >> /orabak/log/full.txt
find /orabak/dbbak -mtime +7 -name "*.log" -exec rm -rf {} \;
echo "complete delete logfile at `date`" >> /orabak/log/full.txt

echo "#######################################################" >> /orabak/log/full.txt
echo "starting delete dumpfile at `date`" >> /orabak/log/full.txt
find /orabak/full -mtime +7 -name "*.dmp" -exec rm -rf {} \;
echo "complete delete dumpfile at `date`" >> /orabak/log/full.txt

echo "#######################################################" >> /orabak/log/full.txt
echo "starting backup of database at `date`" >> /orabak/log/full.txt
expdp "'/ as sysdba'" directory=full_expdp dumpfile=full_%U.dmp full=y parallel=16 compression=ALL filesize=10G logfile=full_expdp.log job_name=expdp_job1;
echo "complete backup of database at `date`" >> /orabak/log/full.txt

mkdir -p /orabak/full/`date +%Y%m%d` && cd /orabak/full/`date +%Y%m%d`
echo "#############################################################" >> /orabak/log/cp.txt
echo "starting copy dumpfile to target file       at `date`" >> /orabak/log/full.txt
cp /orabak/full/*.dmp /orabak/full/`date +%Y%m%d`
cp /orabak/full/*.log /orabak/full/`date +%Y%m%d`
echo "complete copy dumfile `date`" >> /orabak/log/full.txt

如果需要做匯入:
impdp \'/ as sysdba\' directory=imp27 full=y dumpfile=full_%U.dmp logfile=fullimp.log parallel=10 
相關的引數,根據機器的配置來選擇。
匯入的相關注意事項請看http://blog.itpub.net/27099995/viewspace-1348352/

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/30936525/viewspace-2016684/,如需轉載,請註明出處,否則將追究法律責任。

相關文章