Solved

script to create database dumps of multiple tables with different dumpfiles.

Posted on 2012-03-26
8
371 Views
Last Modified: 2012-03-28
Hi Guys,
I have following script export  multiple tables with different dumpfiles.
Please suggest me where I am wrong.


#!/bin/bash
set -x
 if [ $# -lt 3 ]; then
  echo "usage : $0 <sid> <owner> <tab>"
 exit 1
fi
sid=$1
. ~/dbst.env $sid

owner=$2
tab=$3

dumpfile=/allant/"${sid}_${owner}_${tab}.dmp"
 logfile=/allant/"${sid}_${owner}_${tab}.log"

exp "/ as sysdba" log=$logfile   file =$dumpfile tables=${owner}.${tab} rows=yes indexes=no consistent=y statistics=none
0
Comment
Question by:dba1234
8 Comments
 
LVL 29

Expert Comment

by:MikeOM_DBA
ID: 37766886
You cannot export "as sysdba".
:p
0
 
LVL 29

Expert Comment

by:MikeOM_DBA
ID: 37766897
PS: Create an externally identified user:
CREATE USER OPS$ORACLE
  IDENTIFIED EXTERNALLY
  DEFAULT TABLESPACE USERS
  TEMPORARY TABLESPACE TEMP
  PROFILE DEFAULT
  ACCOUNT UNLOCK;
  -- 1 Role
  GRANT DBA TO OPS$ORACLE;
  ALTER USER OPS$ORACLE DEFAULT ROLE ALL;

Open in new window

and execute exp like this:
exp / log=$logfile file =$dumpfile tables=${owner}.${tab} rows=yes indexes=no consistent=y statistics=none

Open in new window

0
 

Author Comment

by:dba1234
ID: 37767032
I have problem with the parameters. Please suggest on them.
0
 
LVL 29

Expert Comment

by:MikeOM_DBA
ID: 37767130
Perhaps remove the space(s0 between the equal "=" signs. like in:
... file =$dumpfile ...
#-Here--^ 

Open in new window

0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 34

Expert Comment

by:johnsone
ID: 37767177
Since when can you not export as SYSDBA?  That used to be a requirement of transportable tablespaces.

I recall you had some hoops to jump through to get the quotes correct.

In fact, current documentation still references the fact that you can (and need to in certain situations):

http://docs.oracle.com/cd/E11882_01/server.112/e22490/original_export.htm#BABFAAIF
0
 
LVL 29

Expert Comment

by:MikeOM_DBA
ID: 37767233
Invoking Export as SYSDBA
SYSDBA is used internally and has specialized functions; its behavior is not the same as for generalized users. Therefore, you should not typically need to invoke Export as SYSDBA except in the following situations:

   
At the request of Oracle technical support
   
When importing a transportable tablespace set

Which is not the case here...
Perhaps I should have posted "should not" instead.
0
 
LVL 34

Expert Comment

by:johnsone
ID: 37767387
OK, I'll agree with "should not export as SYSDBA".  However, to do what is trying to be accomplished here, you need a pretty powerful user.  The user would at least need the EXP_FULL_DATABASE role.  Using SYSDBA would just be easier, probably not the best way, but easier.
0
 
LVL 34

Accepted Solution

by:
Mark Geerlings earned 500 total points
ID: 37768149
Since I'm definitely not a master of UNIX/Linux shell scripting syntax, I prefer to keep this as simple as possible.  For me that means putting all of the Oracle export parameters into a parameter file that "exp" can read when it is called, and that I find easy to edit, understand and/or test, and that leaves me with very simple, one-line syntax at the command line:

$ORACLE_HOME/exp parfile=/home/oracle/scripts/exp.ctl

Here is an example of a parameter file (named: "exp.ctl") that "exp" can read when it is called:

(This one will have "exp" split the output into up to four files, each one almost 2GB in size.)

userid=exp_user/exp_user
file=(/export/exp_LDB1/exp_1.dmp,/export/exp_LDB1/exp_2.dmp,
/export/exp_LDB1/exp_3.dmp,/export/exp_LDB1/exp_4.dmp)
filesize=1980M
log=/var/ora_logs/exp.log
full=Y
rows=Y
indexes=Y
constraints=Y
grants=Y
consistent = Y
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Oracle 12c 10 100
CREATE TABLE syntax 4 44
Last record chosen in Oracle Query 3 34
Dataware house query tuning 9 31
This article started out as an Experts-Exchange question, which then grew into a quick tip to go along with an IOUG presentation for the Collaborate confernce and then later grew again into a full blown article with expanded functionality and legacy…
Working with Network Access Control Lists in Oracle 11g (part 1) Part 2: http://www.e-e.com/A_9074.html So, you upgraded to a shiny new 11g database and all of a sudden every program that used UTL_MAIL, UTL_SMTP, UTL_TCP, UTL_HTTP or any oth…
This video shows how to recover a database from a user managed backup
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now