Link to home
Start Free TrialLog in
Avatar of dbaSQL
dbaSQLFlag for United States of America

asked on

run a PARFILE from a Windows Scheduled task - Oracle export

I have setup the attached to export several schemas from Oracle db. It is a parfile, but renamed to .txt for this post upload.  I used it once manually, and it completed successfully.  Now I need to automate the process to occur daily.  I am told that I can overwrite the output files upon every execution, so no need to date-stamp anything, but I don't know how good I feel about that.  At the very least, I would like to date stamp the log file.  Regardless, when I ran it myself, I maneuvered to the directory of the parfile via the command prompt, and fired expdp like this:          expdp system/password parfile=DailyExport.par

It ran for about 90 minutes and completed successfully.  

I need to do the same, except automated through a Windows Scheduled task on a daily basis.   I am not sure if I can call the parfile as-is through a batch file, or if I  need to be in the Oracle bin directory for the expdp.exe.  Can somebody help me out on this?  Again, I need to call the attached  parfile, exporting these schemas on a recurring, scheduled basis, via Windows Task Scheduler.  Expert guidance is very appreciated.
DailyExport.txt
Avatar of slightwv (䄆 Netminder)
slightwv (䄆 Netminder)

You can create a BAT file but will need to manually set the Oracle environment like ORACLE_SID, ORACLE_HOME and PATH in the BAT file.
Avatar of dbaSQL

ASKER

That is what I was trying to research, slightwv, but it is not 100% clear to me because of the way the parfile is somewhat generic with the DIRECTORY, DUMPFILE and LOGFILE.  Yet the examples I've found online are very specific.  For example, I have copied the content of a bat file I googled below. See the logfile has the drive path and filename, yet in the parfile it's just the filename, 'DailyExport.log'.  Also, the example below includes one schema, and my parfile includes five.  Can you show me the corrections in this bat file example to correspond to my parfile?  I would love a dated log file, for each execution, but it is not totally necessary.   I just need to call the parfile as I posted - from a windows scheduled task, on an automated basis.

@Echo off
D:\Oracle11g\product\11.2.0\dbhome_1\BIN\expdp.exe system/password schemas='ABC' compress=Y directory=expdp_dir dumpfile='expdp_dumpfile_%T.dmp' logfile='c:\dumpfile_exp.log
if %ERRORLEVEL%==0 (echo "Success") else (echo "Failed with error code: " %ERRORLEVEL%)
SOLUTION
Avatar of slightwv (䄆 Netminder)
slightwv (䄆 Netminder)

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of dbaSQL

ASKER

Thank you both for your input.  Much appreciated.