Windows下Oracleデータベース自動バックアップバッチ・スクリプト

4525 ワード

expdbコマンドバージョン
 1 @echo off  
 2 REM ###########################################################  
 3 REM # Windows Server Oracle             
 4 REM #   expdb                      ,sql  :
 5 REM # create or replace directory IRS_DATA_BAK_DIR as 'D:\oraclebak'; 
 6 REM ###########################################################  
 7 REM        ,                 
 8 set CURDATE=%date:~0,4%%date:~5,2%%date:~8,2%
 9 set CURMON=%date:~0,4%%date:~5,2%
10 set CURTIME=%time:~0,2%
11 REM        10,     0  
12 if "%CURTIME%"==" 0" set CURTIME=00
13 if "%CURTIME%"==" 1" set CURTIME=01
14 if "%CURTIME%"==" 2" set CURTIME=02
15 if "%CURTIME%"==" 3" set CURTIME=03
16 if "%CURTIME%"==" 4" set CURTIME=04
17 if "%CURTIME%"==" 5" set CURTIME=05
18 if "%CURTIME%"==" 6" set CURTIME=06
19 if "%CURTIME%"==" 7" set CURTIME=07
20 if "%CURTIME%"==" 8" set CURTIME=08
21 if "%CURTIME%"==" 9" set CURTIME=09
22 set CURTIME=%CURTIME%%time:~3,2%%time:~6,2%
23 REM      、        
24 set OWNER=orcl
25 set USER=app
26 set PASSWORD=app
27 REM        ,     oraclebak/
28 REM     
29 d:  
30 if not exist "oraclebak"                     mkdir oraclebak
31 cd oraclebak
32 set FILENAME=%OWNER%_%CURDATE%_%CURTIME%.DMP  
33 set EXPLOG=%OWNER%_%CURDATE%_%CURTIME%_log.log  
34 REM   ORACLE exp        
35 REM IRS_DATA_BAK_DIR       
36 expdp %USER%/%PASSWORD%@%OWNER% DIRECTORY=IRS_DATA_BAK_DIR DUMPFILE=%FILENAME% LOGFILE=%EXPLOG%
37 REM exp %USER%/%PASSWORD%@%OWNER% file=%FILENAME% owner=%USER% log=%EXPLOG% grants=n
38 REM   rar      
39 "C:\Program Files (x86)\winrar\Rar" a -m5 -dw D:\oraclebak\%OWNER%_%CURDATE%_%CURTIME%".rar" D:\oraclebak\%OWNER%_%CURDATE%_%CURTIME%.DMP  
40 exit   

 
 コンテンツをコピーしたら、拡張子batというファイルに貼り付け、windowsタスクタイミング呼び出しファイルを作成すればいいです.