Home » RDBMS Server » Server Utilities » Script to run EXPDP (10.2.0.4 Windows servers)
Script to run EXPDP [message #676024] Tue, 07 May 2019 10:42 Go to next message
SimonD
Messages: 2
Registered: May 2019
Junior Member
Hi

First off I'm not a DBA.
But learning on the job so to speak.

I would like to run a script which exports (using expdp.exe command) our schema 'companyname'.
I need it to have 2 -3 days of retention 'companyname.dmp' in a specific folder.

Currently we have a script which does this:
EXPDP test/test dumpfile=companyname.dmp DIRECTORY=c:\test ORABACK SCHEMAS=companyname Logfile=companyname


However I want to automate this process plus provided redundancy backups.

Yes I know there is RMAN however this is just an internal test server.

Any help mush appreciated

Re: Script to run EXPDP [message #676025 is a reply to message #676024] Tue, 07 May 2019 10:50 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member

Welcome to this forum

Please read and follow the forum guidelines, to enable us to help you:
OraFAQ Forum Guide
How to use {code} tags and make your code easier to read

How often do you expect/desire script to be invoked?
What is the plan to avoid most recent invocation of script to NOT over write previous dump & log file produced by the script?
Re: Script to run EXPDP [message #676026 is a reply to message #676025] Tue, 07 May 2019 10:53 Go to previous messageGo to next message
SimonD
Messages: 2
Registered: May 2019
Junior Member
How often do you expect/desire script to be invoked?
Daily

What is the plan to avoid most recent invocation of script to NOT over write previous dump & log file produced by the script?
Currently there is a script which uses exp.exe however I want to move away from this and use expdp.exe
Re: Script to run EXPDP [message #676027 is a reply to message #676024] Tue, 07 May 2019 11:03 Go to previous messageGo to next message
John Watson
Messages: 8922
Registered: January 2010
Location: Global Village
Senior Member
You could schedule a Windows shell script (CMD or Powershell) to generate the file names and remove files after a few days. This is a Linux example, I don't have a Windows example to hand but it is straightforward to convert:
#!/bin/bash
. $HOME/.bash_profile
export NLS_DATE_FORMAT=yyyy-mm-dd:hh24:mi:ss
export ORAENV_ASK=NO
export PATH=/u01/app/oracle/product/18.3.0/dbhome_1/bin:$PATH
export SID=cdbprod
find /u02/cdbprod/dump -mtime +6 |xargs rm -vf
for SERVICE in DEV1 DEV2 UAT 
do
expdp system/oracle@$SERVICE directory=dailydump dumpfile=$SERVICE-`date +%Y-%m-%d`.dmp full=y flashback_time=systimestamp logfile=$SERVICE.log
done

Re: Script to run EXPDP [message #676028 is a reply to message #676026] Tue, 07 May 2019 11:05 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
What is the plan to avoid today's invocation of script to NOT over write yesterday's dump & log file produced by the script?

using COPY & PASTE post working expdp command line that produces the desired results for today.
Re: Script to run EXPDP [message #676029 is a reply to message #676024] Tue, 07 May 2019 11:05 Go to previous messageGo to next message
John Watson
Messages: 8922
Registered: January 2010
Location: Global Village
Senior Member
I've just noted that your script doesn't work. This is not a legal directory name:
DIRECTORY=c:\test
Re: Script to run EXPDP [message #676036 is a reply to message #676029] Wed, 08 May 2019 03:04 Go to previous messageGo to next message
cookiemonster
Messages: 13917
Registered: September 2008
Location: Rainy Manchester
Senior Member
To be clear that's not a legal name because datapump needs the name of an oracle directory object, which is a pointer to a real directory on the file server, rather than the name of an actual directory on the file server.

That'll work with exp but not expdp.

[Updated on: Wed, 08 May 2019 03:14]

Report message to a moderator

Re: Script to run EXPDP [message #676042 is a reply to message #676024] Wed, 08 May 2019 06:25 Go to previous message
EdStevens
Messages: 1376
Registered: September 2013
Senior Member
SimonD wrote on Tue, 07 May 2019 10:42
Hi

<snip>
Currently we have a script which does this:
EXPDP test/test dumpfile=companyname.dmp DIRECTORY=c:\test ORABACK SCHEMAS=companyname Logfile=companyname
<snip>
No, you don't have a script that does that. As has already been pointed out, the usage of the DIRECTORY parameter will no work with expdp. And what is that ORABACK between the DIRECTORY and the SCHEMAS parameter?

Actually, aside from getting your expdp command to work (have you read the documentation?) your question has nothing to do with Oracle. It is simply about writing a windows command file and using the Windows scheduler to execute the command file.
Previous Topic: I can't export all tables
Next Topic: External loader with Load When clause
Goto Forum:
  


Current Time: Thu Mar 28 08:55:35 CDT 2024