Files
mip/WebServer/DatabaseScripts/expdp_task.cmd
2008-10-02 09:51:33 +00:00

61 lines
1.5 KiB
Batchfile

REM $Id$
REM
REM Use Oracle data pump to export data, zip the dump file and then move it to the
REM backup directory.
REM
REM Enable extensions so that mkdir can create intermediate directories as required
VERIFY errors 2>nul
SETLOCAL ENABLEEXTENSIONS
IF ERRORLEVEL 1 echo Unable to enable extensions
set dmpbasedir=C:\oracle\admin\webmip\dpdump
set dmpfile=%dmpbasedir%\webmip_data_expdp.dmp
set logfile=%dmpbasedir%\webmip_data_expdp.log
Set destbasedir=S:\orabackup\webmip\DataPump
FOR /F "TOKENS=1-3 DELIMS=/ " %%A IN ('DATE /T') DO (SET yyyy=%%C&set mm=%%B&set dd=%%A)
FOR /F "TOKENS=1 DELIMS=:" %%T IN ('TIME /T') DO SET hr=%%T
Set destdir=%destbasedir%\%yyyy%-%mm%
Set zipfile=webmip_expdp_%yyyy%-%mm%-%dd%-%hr%.zip
erase %dmpfile%
erase %logfile%
expdp 'sys/fmdidgad@webmip as sysdba' parfile=parfile_data.expdp
cmd /c start "7-zip files - started %TIME%" /wait /low 7z a %zipfile% %dmpfile% %logfile%
mkdir %destdir%
move /Y %zipfile% %destdir% && erase %dmpfile%
REM
REM Remove the previous months matching backup
REM
if %mm% LSS 10 (
set tmpmm=%mm:~1,1%
) else (
set tmpmm=%mm%
)
set /a prevmm=%tmpmm% - 1
if %prevmm% LEQ 0 (
set prevmm=112
) else (
set /a prevmm=100 + %prevmm%
)
if %prevmm% EQU 112 (
set /a yyyy=%yyyy% - 1
)
set prevmm=%prevmm:~1,2%
set prevzipfile=webmip_expdp_%yyyy%-%prevmm%-%dd%-%hr%.zip
set prevdestdir=%destbasedir%\%yyyy%-%prevmm%
echo erase %prevdestdir%\%prevzipfile% >> c:\erase_log.txt
erase %prevdestdir%\%prevzipfile%