Compressed Import Script
#!/bin/ksh
############################################################################
#
# Script : imp_db.ksh
#
# Date : 2nd October 2001
#
# Author : Mark Ramsay
#
# Description : This script will perfom an import based on the contents of a parfile using a compressed import file.
#
# 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
#
# imp_<tag>.par
#
# Ensure the file= statement in the parfile conforms to:-
#
# file=<tag>.pip
#
# If a schema import is being performed then the userids must be created first. (Empty ofcourse).
#
# Works with 8i, 9i and 10g. Not tested on 11g.
#
# Parameters : $1 - Oracle sid. (In CAPITALS)
# $2 - Tag.
# $3 - dmp file name. (Do not specify the path)
# $4 - dmp file 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.
#
if [[ $1 = h ]] || [[ $1 = '' ]] || [[ $2 = '' ]] || [[ $3 = '' ]]
then echo ""
echo "Parameters:- "
echo ""
echo "\$1 - Oracle sid."
echo "\$2 - Tag id."
echo "\$3 - The dmp file to be imported."
echo "\$4 - The dmp file path. (Optional) Default=/u01/app/oracle/admin/$ORACLE_SID/dmp"
echo "h - Help e.g. ./exp_schema.ksh h"
echo ""
exit
fi
export ORACLE_SID=$1
if [[ $4 = '' ]]
then echo "No dmp output location specified. Using default location:-"
echo ""
DMPDIR=/u01/app/oracle/admin/$ORACLE_SID/dmp
echo $DMPDIR
echo ""
else echo "\$4 specified. Output location set to:-"
echo ""
DMPDIR=$4
echo $DMPDIR
echo ""
fi
SDS_schema=$2
SDS_dmp_file=$3
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 \$4 being invalid"
echo " or a non existent dmp directory."
echo ""
exit
fi
#
#Check to see if the file exists in the DMPDIR
#
if [ ! -f $SDS_dmp_file ]
then echo "File $SDS_dmp_file does not exist in directory $DMPDIR."
echo "Script exiting..."
exit
fi
#
#Create a pipe buffer and apply uncompress to the pipe.
#
mknod $SDS_schema.pip p
nohup uncompress >$SDS_schema.pip < $SDS_dmp_file &
#
#Run the import
#
imp PARFILE=$PARDIR/imp_$SDS_schema.par
#
#Remove any tmp files and pipes.
#
rm $DMPDIR/$SDS_schema.pip
#
#End the script.
#
exit