Compressed Export Script
#!/bin/ksh 
############################################################################
#
#    Script :    exp_db.ksh
#
#    Date :         2nd October 2001
#
#    Author :    Mark Ramsay
#
#    Description :    This script will perfom an export based on the contents of a parfile.
#             
#    Prerequisites:    Ensure the following directories exist:-
#
#                $ORACLE_BASE/admin/$ORACLE_SID/dmp
#                $ORACLE_BASE/admin/$ORACLE_SID/parfile
#
#            Ensure there is a valid parfile in the parfile directory
#                 Ensure the parfile name conforms to
#
#                       exp_<tag>.par
#
#            Ensure the file= statement in the parfile conforms to:-
#
#                file=<tag>.pip
#
#                 Works with 8i, 9i and 10g.  Not tested on 11g.
#
#       Parameters :    $1 - Oracle sid.  (In CAPITALS)
#                       $2 - Export Tag.   
#                       $3 - dmp file output location.  (Optional)  The default is /u01/app/oracle/admin/$ORACLE_SID/dmp
#
# History       Date      Name      Reason                                      
#               ----      ----      ------                                      
#               dd/mm/yy  zzz       xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
#
# Copyright: www.markramsay.com
#
############################################################################
#
#Set-up variables and parameter validation.
#
clear

if [[ $1 = h ]] || [[ $1 = '' ]] || [[ $2 = '' ]] 
then echo ""                                                                    
     echo "Parameters:- "                                                       
     echo ""                                                                    
     echo "\$1 - Oracle sid."
     echo "\$2 - Schema id."
     echo "\$3 - Output location of dmp file.(Opt) Def=/u01/app/oracle/admin/$ORACLE_SID/dmp"
     echo "h  - Help          e.g.  ./exp_schema.ksh h"
     echo ""
     exit                                                                      
fi

if [[ $3 = '' ]] 
then echo "No dmp output location specified.  Using default location:-"
     echo ""                                                                    
     DMPDIR=/u01/app/oracle/admin/$ORACLE_SID/dmp
     echo $DMPDIR
     echo ""
else echo "\$3 specified.  Output location set to:-"
     echo ""
     DMPDIR=$3
     echo $DMPDIR
     echo ""
fi

export ORACLE_SID=$1
SDS_schema=$2
SCRIPTDIR=/u01/app/oracle/scripts/DBA
PARDIR=/u01/app/oracle/admin/$ORACLE_SID/parfile

#
#Switch to the DMP directory and check to see if it exists.
#

cd $DMPDIR
if [[ $? -ne 0 ]]
then echo ""
     echo "Invalid directory.  This could be due to \$1 or \$3 being invalid"
     echo "                    or a non existent dmp directory."
     echo ""
     exit
fi

#
#Create a pipe buffer and apply compression to the pipe.
#

mknod $SDS_schema.pip p
nohup compress <$SDS_schema.pip >${SDS_schema}_$(date +%d%b)_$(date +%H%M).dmp.Z &

#
#Run the export
#

exp PARFILE=$PARDIR/exp_$SDS_schema.par

#
#Remove any tmp files and pipes.
#

rm $DMPDIR/$SDS_schema.pip

#
#End the script.
#

exit
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License