Thursday, November 5, 2015

using UNIX pipes to export oracle table and compress

Script explanation:

This script is to export the dump file and compress the exported data using UNIX pipes. This method is best suited when there is not enough space on disk. The file exported and compressed at same time, this method will not require much space while exporting the dumpfile.

Note: Using of UNIX pipe's will also speed up the export process & yes there will consume a good amount of CPU.



#!/usr/bin/ksh:


#### This script will export the dumpfile and compress at same time using linux pipe
#### You can use normal gunzip cmd to unzip the zipped file
####

export mydate=`date "+%d%b%Y"`;
export TEST_BAK=TEST_MKNOD_"$mydate";
DUMPFILE=$TEST_BAK".dmp";  ## Setting dumpfile name here
LOGFILE=$TEST_BAK".log";            ## Setting logfile name here
DPUMP=/u01/app/oracle/dpump;                  ## Setting target directory for dump & log



## create exp
## you can use the pipe for compress the file
mknod $DPUMP/exp.pipe p

## compress dmp with file using pipe
gzip < $DPUMP/exp.pipe > $DPUMP/$DUMPFILE.gz &

exp USERNAME/PASSWORD@ORCL file="$DPUMP"/exp.pipe log="$DPUMP/$LOGFILE" tables=TEST statistics=none

## remove the pipe created
rm $DPUMP/exp.pipe

echo $' \n ';

echo " export completed "

No comments:

Post a Comment