【EXP】在備份檔案上留下“時間烙印”

secooler發表於2010-03-25
使用EXP工具備份備份使用者資料時,在備份檔案上打上時間標記是一個非常好的習慣,簡單記錄一下如何在不同的作業系統平臺上完成這個任務,供參考。

1.UNIX或Linux作業系統
1)可以使用date作業系統命令輔助完成這個小任務
secooler@secDB /exp$ exp sec/sec file=`date +"%Y%m%d"`_sec.dmp log=`date +"%Y%m%d"`_sec.log

Export: Release 11.2.0.1.0 - Production on Thu Mar 25 22:51:12 2010

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.


Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, Oracle Label Security, OLAP, Data Mining,
Oracle Database Vault and Real Application Testing option
Export done in ZHS16GBK character set and AL16UTF16 NCHAR character set

About to export specified users ...
. exporting pre-schema procedural objects and actions
. exporting foreign function library names for user SEC
. exporting PUBLIC type synonyms
. exporting private type synonyms
. exporting object type definitions for user SEC
About to export SEC's objects ...
. exporting database links
. exporting sequence numbers
. exporting cluster definitions
. about to export SEC's tables via Conventional Path ...
. . exporting table                              T    1155520 rows exported
. exporting synonyms
. exporting views
. exporting stored procedures
. exporting operators
. exporting referential integrity constraints
. exporting triggers
. exporting indextypes
. exporting bitmap, functional and extensible indexes
. exporting posttables actions
. exporting materialized views
. exporting snapshot logs
. exporting job queues
. exporting refresh groups and children
. exporting dimensions
. exporting post-schema procedural objects and actions
. exporting statistics
Export terminated successfully without warnings.

2)檢視生成的備份檔案
secooler@secDB /exp$ ls -ltr
total 128M
-rw-r--r-- 1 oracle oinstall 1.4K Mar 25 22:51 20100325_sec.log
-rw-r--r-- 1 oracle oinstall 128M Mar 25 22:51 20100325_sec.dmp

OK,生成的備份檔案和日誌檔案均打上了時間的烙印!

2.Windows作業系統
1)看一下在Windows系統中date命令的使用方法
(1)date命令顯示格式
D:\>echo %date%
2010-03-25 週四

(2)只選擇前10位的日期內容
D:\>echo %date:~0,10%
2010-03-25

注意,我們需要選擇日期形式以中橫槓為分隔的形式(如果是“/”分隔的話在生成備份檔案時會報錯)。
修改日期顯示格式的步驟如下:
控制皮膚 --&gt “Clock, Language, and Region”--&gt “Set the time and date” --&gt “Change calendar settings” --&gt “Date formats” --&gt 在“Short date”右側下拉框中選擇“yyyy-M-d”格式。

2)使用Windows作業系統的date命令達到我們的“時間烙印”目的
D:\>exp sec/sec@sec file=%date:~0,10%_sec.dmp log=%date:~0,10%_sec.log

Export: Release 10.2.0.3.0 - Production on Thu Mar 25 23:23:44 2010

Copyright (c) 1982, 2005, Oracle.  All rights reserved.


Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, Oracle Label Security, OLAP, Data Mining,
Oracle Database Vault and Real Application Testing option
Export done in ZHS16GBK character set and AL16UTF16 NCHAR character set

About to export specified users ...
. exporting pre-schema procedural objects and actions
. exporting foreign function library names for user SEC
. exporting PUBLIC type synonyms
. exporting private type synonyms
. exporting object type definitions for user SEC
About to export SEC's objects ...
. exporting database links
. exporting sequence numbers
. exporting cluster definitions
. about to export SEC's tables via Conventional Path ...
. . exporting table                              T    1155520 rows exported
. exporting synonyms
. exporting views
. exporting stored procedures
. exporting operators
. exporting referential integrity constraints
. exporting triggers
. exporting indextypes
. exporting bitmap, functional and extensible indexes
. exporting posttables actions
. exporting materialized views
. exporting snapshot logs
. exporting job queues
. exporting refresh groups and children
. exporting dimensions
. exporting post-schema procedural objects and actions
. exporting statistics
Export terminated successfully without warnings.


3)確認在Windows上生成的備份檔案和日誌檔案的格式
D:\>dir %date:~0,10%_sec*
 Volume in drive D has no label.
 Volume Serial Number is 4CC5-8E99

 Directory of D:\

2010-03-25  23:24       133,310,464 2010-03-25_sec.dmp
2010-03-25  23:24             1,378 2010-03-25_sec.log
               2 File(s)    133,311,842 bytes
               0 Dir(s)  11,578,949,632 bytes free

OK,任務完成。

3.小結
備份命令EXP和作業系統命令date相結合可以很好的實現留下“時間烙印”的目的,當然也可以編寫一段指令碼實現同樣的效果,不過我們最求的是一種簡便易行的方法。

Good luck.

secooler
10.03.25

-- The End --

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/519536/viewspace-630420/,如需轉載,請註明出處,否則將追究法律責任。

相關文章