您的位置:首页 > 运维架构 > Linux

linux下创建expdp备份的计划任务

2018-01-02 00:00 639 查看

linux下创建expdp备份的计划任务

标签: crontabexpdp

2015-12-30 17:22 2102人阅读 评论(0) 收藏 举报


分类:

Oracle 备份恢复(5)


版权声明:本文为博主原创文章,未经博主允许不得转载。

实验目的:

Linux环境下创建计划任务,每天expdp导出scott用户下所有数据进行备份,删除前天的expdp备份文件

实验环境:

备份文件目录:/databack

备份脚本目录:/databack/dbexped_scripts/

mkdir -p /u02/expdp/datas
mkdir -p /u02/expdp/tars

chown -R oracle:oinstall /u02/expdp
chmod -R 775 /u02/expdp

SQL> create directory home as '/home/oracle/expdp/datas';

SQL> grant read,write on directory home to hdlwms;

步骤:

1、创建目录,用于导出

[sql] view plain copy

SQL> create directory dump_dir as '/databack';

2、每天19:00执行一次删除

[plain] view plain copy

[oracle@localhost dbexped_scripts]$ more rm_scottexpdp.sh

export name=`date-d "-2 days" +%F`

rm -f /databack/scott_$name.expdp

rm -f /databack/scott_$name.expdp.log

3、每天20:00执行一次备份

[plain] view plain copy

[oracle@localhost dbexped_scripts]$ more scottexpdp.sh

export ORACLE_SID=orcl

export ORACLE_BASE=/u01/app/oracle

export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1

export LD_LIBRARY_PATH=$ORACLE_HOME/lib

export PATH=$PATH:$ORACLE_HOME/bin

export name=`date-d now +%F`

$ORACLE_HOME/bin/expdp system/systemsystem directory=dump_dir dumpfile=scott_$name.expdp schemas=scott logfile=scott_$name.expdp.log compression=ALL EXCLUDE=STATISTICS

4、执行计划:(每天19:00执行一次删除,每天20:00执行一次备份)

[plain] view plain copy

[oracle@localhost dbexped_scripts]$ crontab -e

0 19 * * * /databack/dbexped_scripts/rm_scottexpdp.sh

0 20 * * * /databack/dbexped_scripts/scottexpdp.sh

5、授予执行权限

[plain] view plain copy

[oracle@localhost dbexped_scripts]$ chmod u+x rm_scottexpdp.sh

[oracle@localhost dbexped_scripts]$ chmod u+x scottexpdp.sh
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: