cxq088 发表于 2009-6-1 11:30:17

oracle数据库自动备份

如何让oracle数据库能自动备份?
环境:linux + oracle
假如数据库的实例名是oracle245,用户名是hhris,密码是hhris,要备份的目录是linux系统的根目录"/",通常我们的用dos命令来操作的,具体命令如下:
exp hhris/hhris@oracle245 file=/oracle245.dmp
但是这样写的文件名是死的,如果我们把命令略加修改,就能生成以日期来命名的文件名:
exp hhris/hhris@Oracle245 file=/%date:~0,4%%date:~5,2%%date:~8,2%.dmp
然后把该命令添加到系统的任务中去,就能自动备份数据库了
导入命令:
imp hhris/hhris@oracle245 file=/oracle245.dmp
========================================================
3.0中,如果要导出
exp system/system file=hhpacs.dmp tables=(accesshold,accesstable,applicationentity,devaccess,device,face,groupnames,securitymatrix,storageaccess,storagecontrol,transmiting,useraccess,patientlevel,studylevel,serieslevel,imagelevel,instancetable,studylevel_old,serieslevel_old,imagelevel_old,instancetable_old)owner=system direct=y log=exp_hhpacs.log
exp hhris/hhris file=hhris.dmp owner=hhris direct=y log=exp_hhris.log
exp hhus/hhus file=hhus.dmp owner=hhus direct=y log=exp_hhus.log
exp hhendo/hhendo file=hhendo.dmp owner=hhendo direct=y log=exp_hhendo.log
==========================================================
4.0中,如果要导出
exp hhapcs/hhpacs file=/zw/hhpacs.dmp owner=hhpacs direct=y log=exp_hhpacs.log
exp hhris/hhris file=/zw/hhris.dmp owner=hhris direct=y log=exp_hhris.log
==========================================================
导入
$sqlplus /”as sysdba”
Sql>create user hhpacs identified by hhpacs default tablespace hhpacs;
Sql>create user hhris identified by hhris default tablespace hhris;
Sql>grant dba to hhpacs;
Sql>grant dba to hhris;
Sql>exit
$imp hhris/hhris file=hhris.dmp fromuser=hhris buffer=40960000 log=imp_hirs.log
$imp hhpacs/hhpacs file=hhpacs.dmp fromuser=hhpacs buffer=40960000 log=imp_hhpacs.log
===========================================================
imp hhpacs/hhpacs file=/zw/hhpacs.dmp fromuser=hhpacs touser=hhpacs log=imp_hhpacs.log
imp hhris/hhris file=/zw/hhris.dmp fromuser=hhris touser=hhris log=imp_hhris.log
页: [1]
查看完整版本: oracle数据库自动备份