expdp通过dblink远程备份数据库案例

sys/Jacjqwl123
--查询 DATA_PUMP_DIR 全路径(F:/app/Administrator/admin/orcl/dpdump/)
select * from dba_directories
--查询已经建立的db_links
select * from dba_db_links;
--drop database link FDJTEST92
--查看SERVICE_NAME
select name,value from v$parameter where name='service_names'
1----------------------- 本机测试连92---------------------------
fdjtest/fdjtest--orcl
create public database link fdjtest92 connect to fdjtest 
identified by fdjtest using '192.168.33.92/orcl'
>>>192.168.33.92/orcl:orcl.是.SERVICE_NAME,取得是tnsnames.ora中的:

TEST =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.33.92)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = orcl)
    )
  )

cmd:
expdp fdjtest/fdjtest directory=DATA_PUMP_DIR dumpfile=fdjtest_%d%.dmp 
network_link=FDJTEST92 logfile=fdjtest_%d%.log CONTENT=ALL

--fdjExpdp.bat:
@echo on
set d=%DATE:~0,4%%DATE:~5,2%%DATE:~8,2%
expdp fdjtest/fdjtest directory=DATA_PUMP_DIR dumpfile=fdjexpdp_%d%.dmp 
network_link=FDJTEST92 logfile=fdjExpdp_%d%.log CONTENT=ALL
@echo on
zip -m F:/app/Administrator/admin/orcl/dpdump/fdjexpdp_%d%.zip 
F:/app/Administrator/admin/orcl/dpdump/fdjexpdp_%d%.dmp
2----------------------- 92测试连136-----------------------------
jac_scl/jac_scl123--92
create public database link jac_scl136 connect to jac_scl 
identified by jac_scl using '192.168.33.136/jqwlscl'
>>>192.168.33.136/jqwlscl:jqwlscl.是.SERVICE_NAME,取得是tnsnames.ora中的:
JQWLSCL =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.33.136)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = jqwlscl)
    )
  )
cmd:
expdp jac_scl/jac_scl123 directory=DATA_PUMP_DIR dumpfile=jacSclExpdp_%d%.dmp 
network_link=jac_scl136 logfile=jacSclExpdp_%d%.log CONTENT=ALL

--jac_sclExpdp.bat:
@echo on
set d=%DATE:~0,4%%DATE:~5,2%%DATE:~8,2%
expdp jac_scl/jac_scl123 directory=DATA_PUMP_DIR dumpfile=jacSclExpdp_%d%.dmp 
network_link=jac_scl136 logfile=jacSclExpdp_%d%.log CONTENT=ALL
@echo on
zip -m F:/app/Administrator/admin/orcl/dpdump/jacSclExpdp_%d%.zip 
F:/app/Administrator/admin/orcl/dpdump/jacSclExpdp_%d%.dmp

 

你可能感兴趣的:(DBlink)