ORACLE 10G的数据泵自动备份脚本

来源:互联网 发布:电脑软件助手下载 编辑:程序博客网 时间:2024/06/10 09:41

项目中遇到客户有这种需求:数据泵每日定时备份一次,保留7个备份。以下脚本可以实现此要求:

[oracle@wh1 oracle]$ cat /opt/oracle/expdp.sh #/bin/shPATH=$PATH:$HOME/binexport PATHexport ORACLE_BASE=/opt/oracleexport ORACLE_HOME=$ORACLE_BASE/product/10.2.0export ORA_CRS_HOME=$ORACLE_BASE/product/crsexport ORACLE_SID=orcl1export PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin:$ORA_CRS_HOME/binexport LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/libexport NLS_LANG=american_america.zhs16gbk now=`date +%Y%m%d`dmpfile=wh$now.dmplog=wh$now.logcd /backup/opt/oracle/product/10.2.0/bin/expdp system/abc123 DUMPFILE=$dmpfile logfile=$log DIRECTORY=dump_dir FULL=Yfind /backup -name "*.dmp" -mtime +7 -exec rm {} \;

[oracle@wh1 oracle]$ crontab -l00 2 * * * /opt/oracle/expdp.sh

说明:脚本实现每天在/backup目录下生成一个dump及导出日志,文件名称根据日期命名。通过OS的定时任务实现每天凌晨两点钟自动备份。脚本自动/backup目录下删除7天前的文件。通过测试,50G的dmp的导出约需要30分钟。在正常情况下还是建议用RMAN进行备份恢复。

Export: Release 10.2.0.5.0 - 64bit Production on Thursday, 07 January, 2016 2:00:01Copyright (c) 2003, 2007, Oracle.  All rights reserved.;;; Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit ProductionWith the Partitioning, Real Application Clusters, OLAP, Data Miningand Real Application Testing optionsStarting "SYSTEM"."SYS_EXPORT_FULL_01":  system/******** DUMPFILE=wh20160107.dmp logfile=wh20160107.log DIRECTORY=dump_dir FULL=Y Estimate in progress using BLOCKS method...Processing object type DATABASE_EXPORT/SCHEMA/TABLE/TABLE_DATATotal estimation using BLOCKS method: 50.09 GBProcessing object type DATABASE_EXPORT/TABLESPACE*****略去****Master table "SYSTEM"."SYS_EXPORT_FULL_01" successfully loaded/unloaded******************************************************************************Dump file set for SYSTEM.SYS_EXPORT_FULL_01 is:  /backup/wh20160107.dmpJob "SYSTEM"."SYS_EXPORT_FULL_01" successfully completed at 02:29:49
0 0
原创粉丝点击