Knowledge Base : Nightly Datapump Export Windows

A Nightly Datapump Whole Database Export on Windows

@echo off
REM Daily Export Script
REM To run this task daily from Windows scheduler: schtasks /create /tn „Daily_IFSSXX_Export“ /sc daily /st 04:00:00 /tr „c:oracleadminscriptsdaily_ifssxx_export.bat“ /RU SYSTEM
SET ORACLE_SID=XXX SET HNAME=example-or01
SET BASE_FOLDER=“D:oraexport%ORACLE_SID%datapump“
SET DUMPFILE_FOLDER=“D:oraexport%ORACLE_SID%datapump“
SET ARCHIVE_PROGRAM=“C:Program Files7-Zip7z.exe“
SET DD=%date:~0,2%
SET MM=%date:~3,2%
SET YYYY=%date:~6,4%
SET T=%TIME: =0%
SET EXPORTDATE=%DATE:~6,4%%DATE:~3,2%%DATE:~0,2% %T:~0,2%%T:~3,2%00
SET BASE_NAME=%YYYY%%MM%%DD%%HNAME%%ORACLE_SID%_fullexp
SET DUMPFILE_NAME=%BASE_NAME%.dmp
SET LOGFILE_NAME=%BASE_NAME%.log
SET BACKUP_FOLDER=%BASE_FOLDER%
SET BACKUP_FILENAME=%BASE_NAME%.zip
expdp ‚/ as sysdba‘ full=y directory=dpdir dumpfile=%DUMPFILE_NAME% logfile=%LOGFILE_NAME% flashback_time=SYSTIMESTAMP
IF %ERRORLEVEL% NEQ 0 GOTO ERROR
%ARCHIVE_PROGRAM% a -tzip %BACKUP_FOLDER%%BACKUP_FILENAME% %DUMPFILE_FOLDER%%DUMPFILE_NAME% %DUMPFILE_FOLDER%% LOGFILE_NAME%
IF %ERRORLEVEL% NEQ 0 GOTO ERROR
DEL %DUMPFILE_FOLDER%%DUMPFILE_NAME%
DEL %DUMPFILE_FOLDER%%LOGFILE_NAME%
EXIT 0
:ERROR
EXIT 1