1

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.

Nicolás Alarcón Rapela
  • 2,714
  • 1
  • 18
  • 29
Andrew
  • 3,632
  • 24
  • 64
  • 113
  • @jeb i have edited my question now – Andrew Feb 03 '16 at 09:39
  • It's still a duplicate, but the errors are: You need to add `setlocal EnableDelayedExpansion` in your batch, then `!` expansion works. And the slash `/` in `!date:~6,2!/!date:~4,2!.dmp` should be probably a `.` – jeb Feb 03 '16 at 09:58
  • @jeb i have edited my question now with you suggestion but still getting same error. I am very new to this concept. I have check your previous quetion but did not get any help from that question and still my problem has not been solved thats why i have edited my question – Andrew Feb 03 '16 at 10:08

1 Answers1

2

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
Andrew
  • 3,632
  • 24
  • 64
  • 113
jeb
  • 78,592
  • 17
  • 171
  • 225