Search code examples
sqloracleexpdp

how to put name difference for daily backup


I created a backup cmd file with this code

EXPDP system/system EXCLUDE=statistics DIRECTORY=bkp_dir DUMPFILE=FULLDB.DMP LOGFILE=FULLDB.log FULL=Y

it works good, but, when I run the backup again, it finds that the file exists and terminate the process. it will not run unless I delete the previous file or rename it. I want to add something to the dumpfile and logfile name that creates a daily difference between them, something like the system date, or a copy number or what else.


Solution

  • The option REUSE_DUMPFILES specifies whether to overwrite a preexisting dump file.

    Normally, Data Pump Export will return an error if you specify a dump file name that already exists. The REUSE_DUMPFILES parameter allows you to override that behavior and reuse a dump file name.

    If you wish to dump separate file names for each day, you may use a variable using date command in Unix/Linux environment.

    DUMPFILE=FULLDB_$(date '+%Y-%m-%d').DMP 
    

    Similar techniques are available in Windows, which you may explore if you're running expdp in Windows environment.