ITPub博客

首页 > 数据库 > Oracle > 使用crontab定期对数据库的schema做逻辑备份

使用crontab定期对数据库的schema做逻辑备份

原创 Oracle 作者:牛肉面之歌 时间:2014-08-21 23:04:18 0 删除 编辑

创建expdp.sh脚本

注意:脚本中需要对环境变量进行设置,否则crontab无法正常运行

#!/bin/bash

PATH=$HOME/bin:/u01/app/oracle/product/10.2.0/db_1/bin:$PATH

export ORACLE_SID=prod

export ORACLE_BASE=/u01/app/oracle

export ORACLE_HOME=/u01/app/oracle/product/10.2.0/db_1

 

export PATH

dmp_file=scott_`date +%Y%m%d_%H%M%S`.dmp

log_file=scott_`date +%Y%m%d_%H%M%S`.log

expdp scott/scott@prod schemas=scott directory=dir dumpfile =$dmp_file logfile=$log_file;


-------------------------------------------------------------------------------------------------------------------------------------------

将脚本加入到crontab中
注意:crontab中的%是换行的含义,需要用\转意

crontab –e

0 23 * * * sh /home/oracle/scripts/bin/expdp.sh>/home/oracle/scripts/log/expdp_scott_`date +\%Y\%m\%d_\%H\%M\%S`.log 2>&1

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

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

注册时间:2014-01-04

  • 博文量
    76
  • 访问量
    115114