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

相关推荐
sky_81061312 小时前
Oracle ERP 各模块业务管理功能及底层表说明
数据库·oracle
ClouGence16 小时前
加一张临时表,OceanBase Oracle 写入居然快了 30 倍!
数据库·sql·oracle
oradh19 小时前
Oracle参数文件(PFILE与SPFILE)维护操作总结
数据库·oracle·oracle参数·spfile·pfile
鸽芷咕19 小时前
【金仓数据库征文】从 Oracle 到金仓:一次零误差的数据库国产化迁移实录
数据库·oracle
05664620 小时前
RAG 向量检索:从“查字“到“查意“
数据库·人工智能·学习·oracle
隔窗听雨眠21 小时前
Oracle到PostgreSQL迁移实战:pg_hint_plan执行计划控制完全指南
数据库·postgresql·oracle
DBA_G1 天前
解析GBase 8s数据库锁机制
数据库·oracle
倔强的石头1061 天前
连接池参数治理-HikariCP怎么配才稳
数据库·oracle
看浪的路人1 天前
第3讲:手写第一个 MCP Server(Python SDK)
jvm·数据库·oracle
oradh1 天前
Oracle RAC OCR维护操作总结
数据库·oracle·ocr·rac ocr维护·ocr维护·vote disk