每天自动备份Oracle数据库,并压缩存档
最近系统测试运行,为了保留历史数据,所以写了一个自动备份数据库的脚本。
首先调用Exp备份,然后调用RAR压缩,并删除原始备份文件。所有备份的压缩文件都是保留的
关于自动执行的问题,我是调用了计划任务,目前一个半小时执行一次 运行了两天 基本正常
Option Explicit
On Error Resume Next
Dim fname, cmd
Dim WshShell
Set WshShell = CreateObject("WScript.Shell")
fname = FormatDateTime(Now(),2)
fname = fname+"-"+FormatDateTime(Now(),4)
fname = Replace(fname,":","-")
cmd = "exp log=../backup/DBBak_" & fname & ".log file=../backup/DBBak_" & fname & ".dmp parfile=exp.txt"
WshShell.run cmd
WScript.Sleep 300000
cmd = """C:\Program Files\WinRAR\rar"" m -ag ..\dbrar\DBBak.RAR ..\backup\DBBak_*.*"
WshShell.run cmd
Set WshShell = Nothing
'WScript.Echo cmd
On Error Resume Next
Dim fname, cmd
Dim WshShell
Set WshShell = CreateObject("WScript.Shell")
fname = FormatDateTime(Now(),2)
fname = fname+"-"+FormatDateTime(Now(),4)
fname = Replace(fname,":","-")
cmd = "exp log=../backup/DBBak_" & fname & ".log file=../backup/DBBak_" & fname & ".dmp parfile=exp.txt"
WshShell.run cmd
WScript.Sleep 300000
cmd = """C:\Program Files\WinRAR\rar"" m -ag ..\dbrar\DBBak.RAR ..\backup\DBBak_*.*"
WshShell.run cmd
Set WshShell = Nothing
'WScript.Echo cmd
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步