A technical troubleshooting blog about Oracle with other Databases & Cloud Technologies.

UNIX Shell Script To Run DataPump Or Traditional Export Or Import Utilities

1 min read
To create a shell script to run export/import utilities. 
# SCRIPT
# ---------
#
# Set environment variables for ORACLE_HOME, ORACLE_SID,
# and DUMPDIR -- in case of datapump --, as well as PATH if needed.
#
#

trap '' 1 # to use nohup in a shell script

# Set these to appropriate values if needed:
#
#ORACLE_HOME=
#ORACLE_SID=
#DUMPDIR=

# Customize PATH if needed
#
#PATH=/bin:/usr/bin:${ORACLE_HOME}/bin:/usr/local/bin:/usr/lbin

#export ORACLE_HOME ORACLE_SID PATH

echo "Exporting $ORACLE_SID database. start `date`"
#
expdp system/password dumpfile=scott.dmp directory=DUMPDIR schemas=scott logfile=scott.log
#
echo "Export of $ORACLE_SID database completed at `date`"

#End of Script
Running the script

If you save the script as exp_comp.sh, type the following command at the Unix prompt to run it:
# ./exp_comp.sh
Note: Edit the above script to use it for your specific exports or imports (like full, schema, table, TTS).

In case of traditional export/imp (exp/imp), the above command may be something like:
exp system/manager file=scott.dmp owner=scott log=scott.log