set adotmp = objconnect.execute("0select tablespace_name from sys.dba_data_files") 得到数据库中的表空间名 dim lnum1 as long dim lnum2 as long lnum = freefile open 自动备份批处理文件路径 for binary as lnum lnum1 = freefile open "onlinebegin.sql" for binary as lnum2 onlinebegin.sql为设置表空间进入热备份模式的脚本文件文件名 lnum2 = freefile open "onlineend.sql" for binary as lnum2 onlinebegin.sql为结束表空间热备份模式的脚本文件文件名 strtmp = " connect 账户名/密码" &. chr(13) &. chr(10) put lnum1, , strtmp strtmp = "shutdown immediate" &. chr(13) &. chr(10) put lnum1, , strtmp strtmp = "startup pfile=初始化文件的存放位置exclusive mount. " &. chr(13) &. chr(10) put lnum1, , strtmp strtmp = "alter database archivelog. " &. chr(13) &. chr(10) put lnum1, , strtmp strtmp = "alter database open. " &. chr(13) &. chr(10) put lnum1, , strtmp strtmp = " connect 账户名/密码" &. chr(13) &. chr(10) put lnum2, , strtmp strtmp = oracle服务管理器路径 &. " @" &. " onlinebegin.sql " &. chr(13) &. chr(10) 在服务管理器中执行脚本文件onlinebegin.sql put lnum, , strtmp do while not adotmp.eof set adotmp1 = objconnect.execute("0select file_name from sys.dba_data_files where tablespace_name= " &. adotmp.fields(0) &. " ") 得到当前表空间所对应的所有数据文件名,通过循环即可得到所有表空间所对应数据文件名,若只备份指定的表空间,可指定表空间名从而得到其对应的物理数据文件 strtmp = "alter tablespace " &. adotmp.fields(0) &. " begin backup." &. chr(13) &. chr(10) 将表空间置于热备份模式 put lnum1, , strtmp strtmp = oracle的ocopy.exe工具全路径 " &. adotmp1.fields(0) &. " " &. 备份文件存放路径 &. chr(13) &. chr(10) put lnum, , strtmp strtmp = "alter tablespace " &. adotmp.fields(0) &. " end backup." &. chr(13) &. chr(10) 表空间恢复正常模式 put lnum2, , strtmp adotmp.movenext loop strtmp = oracle服务管理器路径 &. " @" &. " onlineend.sql" &. chr(13) &. chr(10) 在服务管理器中执行脚本文件onlineend.sql put lnum, , strtmp strtmp = "exit" &. chr(13) &. chr(10) 退出服务管理器 put lnum1, , strtmp strtmp = "alter system switch logfile." &. chr(13) &. chr(10) 强制日志转换,使oracle创建一个归档日志文件 put lnum2, , strtmp strtmp = "exit" &. chr(13) &. chr(10) put lnum2, , strtmp close set adotmp = nothing set adotmp1 = nothing |