1.引用设置环境变量
2.记录执行时间和用户
3.删除旧备份
4.数据泵抽取备份
5.压缩备份
6.删除压缩前的文件

#!/bin/sh
. /etc/profile
source ~/.bash_profile
ORACLE_BASE=/data/u01/app/oracle; export ORACLE_BASE
ORACLE_HOME=/data/u01/app/oracle/product/11.2.0/dbhome_1; export ORACLE_HOME
PATH=/data/u01/app/oracle/product/11.2.0/dbhome_1/bin:/usr/local/bin:/usr/ccs/bin:$PATH:/usr/sbin
export PATH
echo $PATH
date>>/data/u01/app/oracle/exp/zktime10backrun.log
whoami >>/data/u01/app/oracle/exp/zktime10backrun.log
find /data/u01/app/oracle/exp -mtime +5 -name "bak_expdp*.zip" |xargs rm -rf
dmpfile=bakexpdp$(date +%Y%m%d).dmp
logfile=bakexpdp$(date +%Y%m%d).log
zipfile=zktime10bakexpdp$(date +%Y%m%d).zip

expdp user/[email protected]/zktime directory=data_dir dumpfile=$dmpfile full=y log=$logfile;
zip "/data/u01/app/oracle/exp/$zipfile" "/data/u01/app/oracle/exp/$dmpfile" "/data/u01/app/oracle/exp/$logfile"
rm -rf /data/u01/app/oracle/exp/$dmpfile
rm -rf /data/u01/app/oracle/exp/$logfile
~

liunx centos 下oracle expdp备份导出 sh脚本_第1张图片