美文网首页
Windows Server R2下每天定时备份Oracle数据

Windows Server R2下每天定时备份Oracle数据

作者: 飞跑的蛤蟆 | 来源:发表于2017-03-26 01:10 被阅读65次
    • 整个目录结构如下:
      卷 新加卷 的文件夹 PATH 列表
      卷序列号为 9C81-5005
      D:.
      │ backup.log
      │ oracledatabackup.bat
      │ tree.txt

      ├─20161207
      │ ├─data
      │ │ XXX20161207.dmp
      │ │
      │ └─logs
      │ XXX20161207.log

      │_________________________________________________________
    • oracledatabackup.bat文件的内容

    @echo off
    echo 正在进行准备工作,请稍等...... 
    if not exist "\dbbackup\data" md "\dbbackup\%date:~0,4%%date:~5,2%%date:~8,2%\data" 
    if not exist "\dbbackup\logs" md "\dbbackup\%date:~0,4%%date:~5,2%%date:~8,2%\logs" 
    echo 备份文件夹已创建成功!
    echo 当前目录是:D:\dbbackup\%date:~0,4%%date:~5,2%%date:~8,2%\data
    
    Rem echo.>>%cd%\\dbbackup\backup.log
    echo 数据库备份开始,开始时间:%DATE% %time%>>%cd%\\dbbackup\backup.log
    exp userid='XXX/pwd@172.17.1.4/orcl'  file=D:\dbbackup\%date:~0,4%%date:~5,2%%date:~8,2%\data\XXX%date:~0,4%%date:~5,2%%date:~8,2%.dmp log=D:\dbbackup\%date:~0,4%%date:~5,2%%date:~8,2%\logs\\XXX%date:~0,4%%date:~5,2%%date:~8,2%.log
    
    forfiles /p D:\dbbackup\%date:~0,4%%date:~5,2%%date:~8,2%\data /s /m *.* /d -3 /c "cmd /c del @path"  
    forfiles /p D:\dbbackup\%date:~0,4%%date:~5,2%%date:~8,2%\logs /s /m *.* /d -3 /c "cmd /c del @path"
    echo 数据库备份结束,结束时间:%DATE% %time%>>D:\dbbackup\backup.log
    echo ------------------------------------------------------>>D:\dbbackup\backup.log 
    
    Rem 使用Ping命令延时5秒后退出
    ping 127.0.0.1 -n 10>nul 
    echo \dbbackup完成!
    
    • backup.log文件的内容:
      ------------------------------------------------------

    相关文章

      网友评论

          本文标题:Windows Server R2下每天定时备份Oracle数据

          本文链接:https://www.haomeiwen.com/subject/buribttx.html