ITPub博客

首页 > 数据库 > Oracle > Linux或UNIX系统下oracle数据库expdp自动备份

Linux或UNIX系统下oracle数据库expdp自动备份

原创 Oracle 作者:许愿流星1号 时间:2014-11-20 16:32:23 0 删除 编辑

使用EXPDP自动备份数据

1.创建ORACLE Directory对象,如:

 

scott目录=/home/oracle/

 create directory scott as '/home/oracle/';

Grant read,write on directory scott to scott;

 

2.创建备份脚本-

 

#cd /home/oracle/

 

#touch expdp.sh

 

#chmod 775 expdp.sh

 

#vi expdp.sh

 

3.编辑expdp.sh文件内容如下:

 

[oracle@wg1 ~]$ vi expdp.sh

 

#/bin/sh

export ORACLE_SID=prod

export ORACLE_HOME=/home/u01/app/oracle/product/11.2.0/db_1

export NLS_LANG=american_america.zhs16gbk

 

now=`date +%Y%m%d`

 

dmpfile=db$now.dmp

 

echo start exp $dmpfile ...

 

/home/u01/app/oracle/product/11.2.0/db_1/bin/expdp scott/tiger@prod DUMPFILE=$dmpfile DIRECTORY=SCOTT

 

(expdp system/sys@dev DUMPFILE=$dmpfile DIRECTORY=full full=y)

 

mv  -f $dmpfile /home/zengxb/share

 

#删除以前过期的备份

DUMP=/home/zengxb/share

#DUMP_HIS=/u01/oracle/backup_his

find $DUMP -name "*.dmp" -mtime +2 -exec rm {} \;  ------删除超过两天的dmp文件

#find $DUMP_HIS -name "*.dmp" -mtime +10 -exec mv {} /oradata/bak/dmpbaks/ \;

 

 

 

4.编辑crontab文件如下:

 

[root@wg1 oracle]# crontab -e -u oracle

 

51 16 * * *  /home/oracle/expdp.sh  >>/home/oracle/bak.log 2>&1

 

备份出来的是 scott20141027.dmp

 

5.重启crond   不重启也行的

 

#service crond restart

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/29893219/viewspace-1340564/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2014-09-18

  • 博文量
    46
  • 访问量
    430281