Showing posts with label oracle-export-script. Show all posts
Showing posts with label oracle-export-script. Show all posts

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 "

Shell script to export a schema and move it to different server





#!/usr/bin/ksh



### local_path is the data pump directory in local server.

### remote_path is the target location in the remote server.

### RMTSERVER is the ip adress (or) hostname of remote host.



export mydate=`date "+%d%b%Y"`;

local_path=/u01/oracle/DPUMP;

RMTSERVER=10.176.33.99;  ### We are hard coding the remote server here ###

remote_path=/u01/app/oracle/dpump;



## echo "Enter Password:"

##read PASSWORD;



echo "Enter SCHEMA name:"

read SCHEMA;





expdp EXPORT_USER/PASSWORD directory=DPUMP dumpfile="$SCHEMA"_"$mydate".dmp logfile="$SCHEMA"_exp"$mydate".log schemas="$SCHEMA" COMPRESSION=ALL



echo "Export Completed"



cd /u01/oracle/DPUMP;

echo `pwd`

export DUMP_FILE="$SCHEMA"_"$mydate".dmp

sftp $RMTSERVER  <<EOF



cd $remote_path;

put $DUMP_FILE



EOF