Scripts   Home

Oracle Export and Import Compress Scripts

Here are two scripts that export and import databases and make compressed files for Oracle. Tested on Oracle 8.0.5 and Sun 2.7 If the resulting compressed file is too big for the file system you can run the file through the Unix utility "split" to make smaller files.


#!/bin/ksh
# Export with flags (full, consistent) to a compressed file that 
# is named by SID-month-day using Oracle exp
##############################################
# Main

# Configure environment
. oracle_environment.ksh   # Oracle environment.
export ORACLE_SID=XXX1

DIRECTORY=/apps/home/oracle/local; export DIRECTORY
FILENAME=${DIRECTORY}/Exports/${ORACLE_SID}-`date +%d`.dmp.gz; export FILENAME
LOG=${DIRECTORY}/Exports/${ORACLE_SID}-`date +%d`.log; export LOG
PIPE=${DIRECTORY}/export_pipe.dmp; export PIPE

test -p ${PIPE} || mknod ${PIPE} p
chmod +rw ${PIPE}

cat $PIPE | /usr/local/bin/gzip > ${FILENAME} &
${ORACLE_HOME}/bin/exp log=${LOG} buffer=10485760 file=${PIPE} consistent=yes fu
ll=yes << EOF
system/password 
EOF
#############################################################



#!/bin/ksh
# Oracle imp import for gzipped Oracle exp file.
##############################################
# Main

# Path of exp file.
FILENAME=$1; export FILENAME

PIPE=export_pipe.dmp; export PIPE
test -p ${PIPE} || mknod export_pipe.dmp p
chmod +rw ${PIPE}

/usr/local/bin/zcat ${FILENAME} > ${PIPE} &
${ORACLE_HOME}/bin/imp buffer=10485760 file=${PIPE} full=yes log=impzip.log << EOF
system/password
EOF
#########################################################

The views and opinions expressed in this page are strictly those of the page author.
The contents of this page have not been reviewed or approved by the University of Minnesota.