当前位置:首页 > 开发 > 数据库 > 正文

sqlserver 2005 定时任务计划 批量文件备份脚本

发表于: 2011-11-22   作者:bozch   来源:转载   浏览:
摘要: 在网上找一了一个多数据库同时备份的脚本,之前存在少许问题作了更改,脚本如下: @echo offset svr=sqldbset svrrole=bozchset nowtime=%date:~0,10% %time%set year=%date:~0,4%set month=%date:~5,2%set day=%date:~8,2%set today=%year%-%month%-%day%

在网上找一了一个多数据库同时备份的脚本,之前存在少许问题作了更改,脚本如下:

@echo off
set svr=sqldb
set svrrole=bozch
set nowtime=%date:~0,10% %time%
set year=%date:~0,4%
set month=%date:~5,2%
set day=%date:~8,2%
set today=%year%-%month%-%day%
if "%time:~0,1%" == " " (set nowh=%time:~1,1%) else (set nowh=%time:~0,2%)
  set rar="c:\Program Files\WinRAR\Rar.exe"
  set rarlist="D:\backupdb\script\rarlst.txt"
  set ftplist="D:\backupdb\script\ftplst.txt"
  set baklog=D:\backupdb\script\tkblbackup.log
@echo. >> %baklog%
@echo -------------------------------------------------- >> %baklog%
@echo %nowtime% BackupScript is starting....... >> %baklog%

::数据库备份语句,可添加多个数据库
  for %%a in (test) do (
  @echo %nowtime% BackupDB %%a is beginning....... >> %baklog%
  @osql -s localhost -U sa -P sa -Q "backup database %%a to disk='D:\backupdb\backupdb\%%a_%svr%_%today%.bak' with init" >> %baklog%
  echo D:\backupdb\backupdb\%%a_%svr%_%today%.bak >> %rarlist%
  )
::Rar files
  %rar% a D:\backupdb\backupdb\%svrrole%_%svr%_%today%.bak.rar @%rarlist%  >> %baklog%
  cd /d D:\backupdb\backupdb
  del *.bak

echo. > %rarlist%
@echo -------------------------------------------------- >> %baklog%
@echo. >> %baklog%

(引用:http://www.hackbase.com/tech/2011-05-04/63571.html)

sqlserver 2005 定时任务计划 批量文件备份脚本

  • 0

    开心

    开心

  • 0

    板砖

    板砖

  • 0

    感动

    感动

  • 0

    有用

    有用

  • 0

    疑问

    疑问

  • 0

    难过

    难过

  • 0

    无聊

    无聊

  • 0

    震惊

    震惊

版权所有 IT知识库 CopyRight © 2009-2015 IT知识库 IT610.com , All Rights Reserved. 京ICP备09083238号