#!/bin/sh
# ##################################################################
# Powered by Ironfo
# ##################################################################
# Oracle Environment settings
source /home/oracle/.bash_profile
backup_dir=/home/oracle/backup/dump_dir export backup_dir
cd $backup_dir
#可以创建数据泵目录directory,这里指定默认的目录
#SQL>CREATE DIRECTORY dump_backup_dir as '/u01/oradata/dump_backup_dir';
#SQL>grant read,write on directory dump_backup_dir to user;
DMP_FILE=zyscm_$(date +%Y%m%d_%H%M%S).dmp
LOG_FILE=zyscm_$(date +%Y%m%d_%H%M%S).log
#
# Let's start with an export of the database
expdp zyscm/zyscm@orcl schemas=ZYSCM DUMPFILE=$DMP_FILE logfile=$LOG_FILE directory=DUMP_DIR content=all compression=all;
#expdp user/pwd@orcl schemas=schema_name DIRECTORY=$dump_backup_dir DUMPFILE=$DMP_FILE logfile=$LOG_FILE compression=all parallel=3;
# 这里的2个说明,用户名和密码换成自己的,我这里是备份表空间。
# parallel 这个参数是控制并行度的,默认是1,但对于数据库比较大的时候,可以设置parallel,这样可以较少备份的
#时间,但是设置并行会耗CPU 资源,如果CPU 资源比较紧张的话,就不要设了。
#
# Just to be safe (with space), we'll compress the export file
# 压缩dmp 文件,较少对空间的占用
#compress *.dmp
#
# Let's delete the backups and logs that are more than 1 days old
# 删除2天前PH_开头的dmp文件
#
cd $backup_dir
find $backup_dir -mtime +2 -name "zyscm_*" -exec rm -f {} \;
#That's all