Automatic bash script to perform full export and then full import to a DB
875161Sep 18 2012 — edited Sep 19 2012Hi all,
I am trying to implement automatic routine that makes full export from a Prod DB, then transfer the dump to another host, and then perform an full import to another DEV database.
Both two machines are using the same platform - RHEL5 Linux x86_64 and have password-less SSH login setup between them. Both databases are 11gR1.
What I've tried sofar is to do the above with a bash script. The export part is working fine:
#! /bin/ksh
tim=`date +20'%y-%m-%d`
export flash='"'"TO_TIMESTAMP('$tim 17:00:00','YYYY-MM-DD HH24:MI:SS')"'"'
echo "flashback_time="$flash > /usr/local/bin/fb.par
rm /dump/dp_db1.log
rm /dump/dp_db1.dmp
/bin/su - oracle -c "expdp system/xxxxxx FULL=y dumpfile=dump_dir:dp_db1.dmp logfile=log_dir:dp_db1.log COMPRESSION=ALL parfile=/usr/local/bin/fb.par"
chmod 644 /dump/dp_db1.log
chmod 644 /dump/dp_db1.dmp
scp /dump/dp_larry1.dmp root@xx.xx.xx.xx:/opt/oracle/home/dumps
scp /dump/dp_larry1.log root@xx.xx.xx.xx:/opt/oracle/home/dumps
## After export is done execute remote script through ssh in the background
ssh root@xx.xx.xx.xx "nohup /opt/oracle/home/dumps/myprogram &>/opt/oracle/home/dumps/myprogram.log"
But I don't know how to proceed with the import part (the myprogram script itself).
My main concern is how to drop ALL database objects on the DEV prior the import?
After somehow doing this, I'll then would be able to include in my script simple command to do the import:
impdp \'/ as sysdba\' directory=DUMP dumpfile=dp_db1.dmp full=y
Can someone please advise?
Thank you in advance!