oracle-databasebatch-filedatabase-backupsexpdp

Ora-39000 bad dump file specification when exporting dump file using expdp


I am trying to perform a windows scheduler job which will create back up of my database daily once. So for this reason I have created batch file SYSTEM_BACKUP.bat which contains data:

@echo off
setlocal EnableDelayedExpansion
expdp SYSTEM/SYSTEM@XE PARFILE=export_dump.par

The export_dump.par file contains information:

DIRECTORY=cron_jobs
DUMPFILE=SYSTEM_!date:~10,4!!date:~6,2!.!date:~4,2!.dmp
LOGFILE=SYSTEM.log
SCHEMAS=B1,B2
CONTENT=ALL

When i trying to run the SYSTEM_BACKUP.bat I am getting error as

  ORA-39001:invalid argument value,
  ORA-39000 bad dump file specification,
  ORA-39087:directory name ratormonitor_!date is invalid. 

I am trying to create dump file with current datetimestamp attached to the file so the dump file name should look like this SYSTEM_2015.02.03.37.029062831 but getting an error.


Solution

  • Your export_dump.par file contains

    DUMPFILE=I_!date:~10,4!!date:~6,2!.!date:~4,2!.dmp
    

    But as this isn't part of a batch file, the process expdp.exe which reads the file doesn't know anything about delayed expansion or variable expansion at all.

    So you have to create this file by your batch file each time before you start expdp

    @echo off
    setlocal EnableDelayedExpansion
    (
        echo DIRECTORY=cron_jobs
        echo DUMPFILE=I_!date:~10,4!!date:~6,2!.!date:~4,2!.dmp
        ...
    ) > export_dump.par
    expdp SYSTEM/SYSTEM@XE PARFILE=export_dump.par