oracle 数据库备份脚本(数据泵1-全库)

#!/bin/sh
# ##################################################################
# Powered by Ironfo
# ##################################################################
# Oracle Environment settings
ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/db_1; export ORACLE_HOME
export ORACLE_SID=实例名
export PATH=$PATH:$ORACLE_HOME/bin
backup_dir=/bak
#创建数据泵目录directory,DBBAK
#SQL>CREATE DIRECTORY DBBAK as '/bak';
#SQL>grant read,write on directory DBBAK to 用户;
DMP_FILE=PH_$(date +%Y%m%d_%H%M%S).dmp
LOG_FILE=PH_$(date +%Y%m%d_%H%M%S).log
#
# Let's start with an export of the database
expdp 用户名/密码@ip/实例名(或 TNS)   full=y directory=DBBAK DUMPFILE=$DMP_FILE logfile=$LOG_FILE ;

#
# Let's delete the backups and logs that are more than 1 days old
# 删除2天前PH_开头的dmp文件
#
cd $backup_dir
find $backup_dir -mtime +7 -name "PH_*" -exec rm -f {} ;

原文地址:https://www.cnblogs.com/zhm1985/p/12667118.html