Hi all,
I need your help to write a Unix ksh script for perform an Oracle exp and imp and to ftp or sftp schema and username as two parameter in the script.
User will pass in
1)source schema name
2)Source table name
3)Target server where the file needs to be moved (optional)
4)The script need to generate the export file
The script needs to use pipes to compress space of the export files and error handling.
Here is what I have thus far:
ORACLE_SID=MYSID
export ORACLE_SID
DIRECTORY=/app/oracle/work; 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 $1 tables=$2 log=${LOG} buffer=10485760 file=${PIPE} consistent=yes full=no << 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 $1 $2 buffer=10485760 file=${PIPE} log=impzip.log << EOF
system/password
EOF