UNIX Shell ScriptFull Database Import |
Full database import and uncompress using named pipes.You will need this if you use the full database export script.
$1 (MANDATORY) - ORACLE_SID of the database to
import
$2 (MANDATORY) - The directory of the compressed import file
$3 (MANDATORY) - The database connect string to import from.
#!/bin/ksh
DATABASE=$1 DUMPDIR=$2 USERPASS=$3
# Check that we have a database to start if [ -z "${DATABASE}" ] then echo echo "No Database Specified !" echo echo "Usage : fulldbimport.ksh <ORACLE_SID> <DUMPDIR> <CONNECT STRING>" echo echo "where ORACLE_SID (Mandatory) - SID of database to start" echo " DUMPDIR - Directory of the compressed import file" echo " CONNECT - Username/Password of the database user to import from." echo echo " e.g. $ fulldbimport.ksh PROD /dbexport system/manager" echo exit 1 fi
# Check the dump directory exists if [ ! -d "${DUMPDIR}" ] then echo echo "$DUMPDIR does not exist !" echo exit 1 fi
# Check we have an Oracle username and password if [ -z "${USERPASS}" ] then echo echo "No Database connect string specified !" echo echo "Usage : fulldbimport.ksh <ORACLE_SID> <DUMPDIR> <CONNECT STRING>" echo echo "where ORACLE_SID (Mandatory) - SID of database to start" echo " DUMPDIR - Directory of the compressed import file" echo " CONNECT - Username/Password of the database user to import from." echo echo " e.g. $ fulldbimport.ksh PROD /dbexport system/manager" echo exit 1 fi
# Get the ORACLE_HOME from the oratab file ORACLE_HOME=`cat /etc/oratab | grep $DATABASE | awk -F: '{print $2}'` if [ ! -d "${ORACLE_HOME}" ] then echo echo "$ORACLE_HOME does not exist !" echo exit 1 fi
ORACLE_SID=$DATABASE export ORACLE_SID PATH=.:$ORACLE_HOME/bin:$PATH; export PATH
LOGFILE=$DUMPDIR/imp${ORACLE_SID}_full.log PIPEFILE=$DUMPDIR/PIPE.dmp
# Check we have created the named pipe file, or else there is no point # continuing if [ ! -p ${PIPEFILE} ] then echo echo "Create the named pipe file ${PIPEFILE} using " echo " $ mknod p $DUMPDIR/PIPE.dmp" echo exit 1 fi
# Create a new empty logfile exec >$LOGFILE 2>&1 echo echo "*******************************************************" echo "* Importing ${ORACLE_SID} database at `date`" echo "*******************************************************" echo
uncompress < $DUMPDIR/imp${ORACLE_SID}_full.dmp.Z > ${PIPEFILE} | imp $USERPASS full=y ignore=y commit=y buffer=1000000 file=${PIPEFILE}
echo echo "*******************************************************" echo "* Import Completed at `date`" echo "*******************************************************" echo
exit 0
Return to Index of SQL Scripts
Home
|
Company Profile
|
Services
|
Contact Us
|
SQL scripts and tips
|
Quiz
|