Liunx下的Oracle备份

来源:互联网 发布:手机版淘宝怎么开店 编辑:程序博客网 时间:2024/06/06 20:42
1、配置环境变量
ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1; export ORACLE_HOME
LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib; export LD_LIBRARY_PATH
ORACLE_SID=ecology; export ORACLE_SID
ORA_NLS33=$ORACLE_HOME/nls/admin/data; export ORA_NLS33
NLS_LANG=american_america.zhs16gbk;export NLS_LANG
PATH=$ORACLE_HOME/bin:$PATH; export PATH

2、配置sh文件
date="$(date -d now +%Y%m%d%H%M)"
days=7
orowner=ecology
bakuser=ecology
bakpass=ecology
bakfile=$orowner"_"$date.dmp
baklog=$orowner"_"$date.log
bakdir=/home/oracledata
ordbak=$orowner"_"$date.tar.gz
cd $bakdir
expdp $bakuser/$bakpass@ecology directory=expdpdata dumpfile=$bakfile logfile=$baklog  schemas=$orowner;
tar -zcvf $ordbak $bakfile $baklog
find $bakdir -type f -name "*.dmp" -exec rm -f {} \;
find $bakdir -type f -name "*.log" -exec rm -f {} \;

find $bakdir -type f -name "*.tar.gz" -mtime +$days -exec rm -f {} \;


3、创建自动运行作业即可

0 0