Thursday, November 5, 2015

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

No comments:

Post a Comment