oracle 备份脚本

oracle 备份脚本

        该脚本对数据库进行完全备份,然后打包,以备份日期命名打包文件,以便于日后恢复。稍修改一下脚本可以实现增量或其它备份

-------------txt-----------
userid=user/passwd@db
owner=user
INDEXES=y
grants=y
rows=y
constraints=y
compress=N
-----------txt end---------

-------------vbs-----------
Option Explicit

On Error Resume Next

Dim log_fname, dmp_fname, exp_fname, rar_fname, fname, cmd
Dim WshShell

Set WshShell = CreateObject("WScript.Shell")

'备份数据库
log_fname = "'.\Data\ysgl_" & Date & ".log'"
dmp_fname = "'.\Data\ysgl_" & Date & ".dmp'"
exp_fname = ".\exp_ysgl.txt"
cmd = "exp log=" & log_fname & " file=" & dmp_fname & " parfile=" & exp_fname
WshShell.run cmd,,True

'压缩数据库
fname = """.\Data\ysgl_" & Date & ".*"""
rar_fname = """.\Data\ysgl_" & Date & ".rar"""
cmd = "rar.exe a -ep -m5 " & rar_fname & " " & fname
WshShell.run cmd,,True

'删除临时文件
cmd = ".\delete.bat"
WshShell.run cmd,,True

Set WshShell = Nothing
------------vbs end-----------

---------------bat--------------
del ".\Data\*.dmp"
del ".\Data\*.log"
------------bat end-------------

可以把vbs加入计划任务实现自动备份

你可能感兴趣的:(oracle 备份脚本)