四海人民公摄 - 海外华人摄影爱好者论坛

 找回密码
 注册
搜索
热搜: 活动 交友 discuz
查看: 2009|回复: 0

MS SQL Server database backup solution

  [复制链接]
发表于 2011-6-10 10:53:07 | 显示全部楼层 |阅读模式
The following has been tried and work well

In task scheduler:
  1. sqlcmd -i "E:\db_backup\ADbk.sql"
复制代码

where E:\db_backup\ADbk.sql is the backup script to run, which contains the codes:
  1. DECLARE @MyFileName varchar(50)
  2. SELECT @MyFileName = (SELECT 'E:\db_backup\ADbk_' + datename(dw,GetDate()) + '.bak')
  3. BACKUP DATABASE [AD] TO DISK = @MyFileName WITH NOFORMAT, INIT, NAME = N'AD-Full Database Backup'
  4. GO
复制代码

This will include day of the week in the backup file name. Thus 7 copies of backup files always kept.

Note
INIT = overwire existing file
NOINIT = append to existing file
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|四海人民公摄 - 海外华人摄影爱好者网站

GMT+8, 2024-11-23 19:37

Powered by Discuz! X3.5

Copyright © 2001-2023 Tencent Cloud.

快速回复 返回顶部 返回列表