expdp file 带时间戳 date

Applies To

All Users

Summary

How to create dumpfile and logfile with timestamp in their names while using expdp?

This is required by users who have scheduled their daily export (using expdp) as a job and don't want their dumpfile or the logfiles to be overwritten.

Solution

There is no such option in expdp for giving timestamp in the names of the dumpfile or the logfile but it can be achieved using the following script. The suggestion is to generate an expdp command line using a shell/batch script by adding the timestamp in the names of dumpfile and logfile. For example, if a full export is taken, then the command would be:
#> expdp system/<PASSWORD> DIRECTORY=DATA_PUMP_DIR DUMPFILE=testdmp.dmp LOGFILE=testlog.log full=y

Now the above command will generate dumpfile and logfile with the names testdmp.dmp and testdmp.log respectively. But if you want to include the timestamp in their names then the above expdp command can be broken into parts in a shell script and the complete command can be generated dynamically.
-- On UNIX Platforms
vi expdpts.sh

cd $ORACLE_HOME/bin

cmd1="expdp system/<PASSWORD> DIRECTORY=DATA_PUMP_DIR DUMPFILE=testdmp"
dmpfile=`date +%Y-%m-%d-%H-%M-%S`
cmd2=".dmp LOGFILE=testlog"
cmd3=".log full=y"

totcmd=cmd1dmpfilecmd2dmpfilecmd3 totcmd

$ sh expdpts.sh

You can also use something similar to:
expdp .... dumpfile=expdp_'date +"%Y%b%d-%H%M%S"'.dmp logfile=log_expdp_'date +"%Y%b%d-%H%M%S"'.log job_name=job_'date +"%Y%b%d-%H%M%S"'

-- On Windows platforms
c:>edit expdpts.bat

set cmd1=expdp system/<PASSWORD> DIRECTORY=DATA_PUMP_DIR DUMPFILE=testdmp
set time_=%time: =0%
set dmpfile=%date:~6,4%-%date:~3,2%-%date:~0,2%-%time_:~0,2%-%time_:~3,2%-%time_:~6,2%
set cmd2=.dmp LOGFILE=testlog
set cmd3=.log full=y
set totcmd=%cmd1%%dmpfile%%cmd2%%dmpfile%%cmd3%
%totcmd%

c:\>expdpts.bat

The following export will be started:
expdp system/<PASSWORD> DIRECTORY=DATA_PUMP_DIR DUMPFILE=testdmp2012-08-31-08-04-59.dmp LOGFILE=testlog2012-08-31-08-04-59.log full=y

Attachments :

Article Feedback

相关推荐
ClouGence4 天前
Oracle 数据同步为什么会出现数据不一致?长事务是常被忽略的原因
数据库·后端·oracle
ClouGence10 天前
Oracle CDC 架构优化:从主库直连到 DataGuard 备库同步
数据库·后端·oracle
曹牧11 天前
Oracle EXPLAIN PLAN
数据库·oracle
贤时间11 天前
codex 助力oracle ebs 开发
数据库·oracle
秉承初心11 天前
PostgreSQL 数据性能瓶颈突破实战
数据库·postgresql·oracle
Curvatureflight11 天前
MySQL 深分页越来越慢?从 LIMIT OFFSET 改成游标分页
数据库·oracle
XZ-07000111 天前
MySQL事务
数据库·mysql·oracle
tiancaijiben11 天前
阿里云函数计算FC如何实现网站的定时任务与自动化
数据库·oracle·dba
xfhuangfu11 天前
Oracle 19c 多租户体系架构介绍
数据库·oracle·架构
杨云龙UP11 天前
Spotlight 接入 Oracle 数据库监控操作指南 2026-06-16
数据库·oracle·性能监控·预警·阈值·spotlight·瓶颈分析