登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

xixilive的博客

责人之心,恕己之心——Mickey!

 
 
 

日志

 
 

SQLExpress 2005 自动备份  

2008-09-19 12:19:50|  分类: .NET |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |
2-3步实现SQL Express 2005 数据库自动备份
第一步:创建存储过程(master库)
方式一:进入cmd,运行命令 sqlcmd -S 数据库服务器名 -E -i 存储过程的sql文件(expressmaint.sql)
方式二:如果装有Manage Studio工具,则可以直接进入数据库创建存储过程;

上文提到的expressmaint.sql请参看我的相关日志内容
SQLExpress 2005 自动备份的存储过程(I)
SQLExpress 2005 自动备份的存储过程(II)

第二步:创建批处理文件
新建文本文件,改名为BackUp.bat,
------------------------------------------------------
@echo off
ExpressMaint -S MAIDI\SQLEXPRESS -D ALL_USER -T DB -B D:\WEB_DATA_BACKUPS\DATA -R D:\WEB_DATA_BACKUPS\Reports -RU WEEKS -RV 1 -BU WEEKS -BV 1 -V -C
-------------------------------------------------------
在 BackUp.bat文件中键入以上代码,保存在合适的位置。
(注意:备份文件和备份报告文件的存储目录应该赋予SQLServer相关用户组的写权限)

上文提到的ExpressMaint命令请参看:
http://www.codeplex.com/ExpressMaint

第三步:创建系统任务计划
创建一个计划任务,定时运行上述批处理文件。


附:ExpressMaint命令参数表
Switch
Argument
Required
Description
-?
N
N
Displays help for the ExpressMaint utility
-S
Y
Y
The SQL Server for ExpressMaint to connect to
-D
Y
Y
The target database for the maintenance operation. Valid values are a single database name, ALL_USER which will process all user databases, ALL_SYSTEM which will process all system databases and ALL which will process all databases
-T
Y
Y

The type of maintenance operation to be performed. Valid values are

  • DB - Full Database Backup
  • DIF - Differential Database Backup
  • LOG - Log Backup
  • CHECKDB - Database Integrity Check
  • REINDEX - Rebuild all indexes
  • REORG - Reorganize all indexes
  • STATS - Update all statistics using default sampling
  • STATSFULL - update all statics with fullscan
-B
Y
N
The base folder to write the backups to. Sub folders will be created for each database
-V
N
N
Indicates whether to verify the backup file
-BU
Y
N
The unit of measure for the -BV argument. Valid values are minutes, hours, days, weeks. The combination of these two arguments determines for how long old backup files are kept. Required if -B argument is specified.
-BV
Y
N
The time period of old backups to keep. Required if -B argument is specified.
-R
Y
N
The folder where maintenance reports are written to
-RU
Y
N
The unit of measure for the -RV argument. Valid values are minutes, hours, days, weeks. The combination of these two parameters determines for how long old reports are kept. Required if -R argument is specified.
-RV
Y
N
The time period or number of copies of old reports to keep. Required if -R argument is specified.
-A
N
N
Indicates whether to check the archive bit on a backup file before deleting it. This is a safety check to prevent deletion of files that have not been backed up onto tape.
-DS
N
N
If this switch is specified then the timestamp for backup and report files is appended to the front of the filename (the default is to append to the end of the filename)
-TO
Y
N
This switch allows the setting of a statement timeout specified in minutes (e.g. -TO 10). If not specified, the default is 10 minutes.
-C N N This switch allows multi database maintenance operations (ALL,ALL_USER,ALL_SYSTEM) to continue if an error is encountered with one or more databases


  评论这张
 
阅读(1298)| 评论(0)

历史上的今天

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2018