Sunday, January 23, 2011

Compress EXP/IMP Using Pipes

exporting using pipe:-

$ mknod exp_p.pipe p
$ gzip -c < exp_p.pipe > /home/oracle/full_db.gz &
$ exp "'sys/admin@orcl as sysdba'" file=exp_p.pipe full=y log=full.log

a) create a pipe file using mknod utility.

b) The gzip will compress the data which are received through the pipe and
it will create a gz (zip) file as full_db.gz, start this to run
in the background.

c) when expoing the data in the file parameter give the name of the
pipe file which been started using the mknod utility.

Importing using pipe:-

$ mknod imp_p.pipe p
$ gunzip -c < full_db.gz > /home/oracle/imp_p.pipe &
$ imp "'sys/admin@orcl as sysdba'" file=imp_p.pipe tables=emp fromuser=manzoor touser=manzoor

a) Create a pipe file using mknod utility.

b) the gunzip will uncomrpress the compressed file and and tranfer it
to the imp_p.pipe file.

c) when importing the data, in the file parameter give the name of the
pipe which is recived the data from the gunzip.


# Script to take Full export using pipe.


rm -f newer_than_2.pipe wc.log newer_than_2.log
mknod newer_than_2.pipe p
$GZIP -c $dmpf &
exp parfile=newer_than_2.par
if [ $? -eq 0 ] ; then
echo "***"
echo "*** SUCCESS exp parfile=newer_than_2.par"
echo "***"
echo "*** FAIL exp parfile=newer_than_2.par exit"
exit 1

# confirm export file exists
echo "***"
echo "*** export file:"
ls -l $dmpf

Note : If you have enough space in the target server you can also directly uncompress / gunzip the dumpfile and pass it to import tool as below.

$ gunzip  full_db.gz

$ imp "'sys/admin@orcl as sysdba'" file=full_db tables=emp fromuser=manzoor touser=manzoor

No comments:

Post a Comment