ORACLE 生产库测试库同步

同步频率:一天一次
 
生产服务器:每天1点运行
#Description: 2012-06-15 
#1. Export the data of oms schema from prod database oms 10.101.5.20;
#2. Transfer the dmp file to Test database server 10.101.5.36;
 
today=`date +%Y%m%d`
 
expdp system/xxxx@oms directory=datamove dumpfile=oms_$today.dmp logfile=oms_export_$today.log schemas=oms
 
cd /database/datamove
 
scp oms_$today.dmp oracle@10.101.5.36:/tmp/datamove
 
rm -rf oms_$today.dmp
 
测试服务器:每天2点运行
#Description: 2012-06-15 Tom
#1. Delete user oms including the objects and create user oms
#2. Import the data of oms schema into Test database oms
#3. Delete the dmp file
 
today=`date +%Y%m%d`
 
export ORACLE_SID=oms
 
sqlplus /nolog<<EOF
conn sys/xxxx as sysdba
drop user oms cascade;
 
create user oms identified by xxx default tablespace USERS temporary tablespace TEMP profile DEFAULT;
grant connect to OMS;
grant resource to OMS;
grant create materialized view to OMS;
grant unlimited tablespace to OMS;
EOF
 
impdp system/xxxx@oms directory=datamove dumpfile=oms_$today.dmp logfile=oms_import_$today.log schemas=oms
 
cd /tmp/datamove
 
rm -rf oms_$today.dmp

Comments

Popular posts from this blog

Nginx Proxy & Load Balance & LNMP

Snort+barnyard2+Snorby CentOS 6.5_64 Installation

ORACLE Error