昂捷论坛≡FAQ≡□-系统配置管理类 → 问:简单做异地备份的脚本是怎样的?


  共有24816人关注过本帖树形打印

主题:问:简单做异地备份的脚本是怎样的?

帅哥哟,离线,有人找我吗?
飞絮
  1楼 个性首页 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:中校 帖子:594 积分:6649 威望:0 精华:56 注册:2005/10/21 18:45:15
问:简单做异地备份的脚本是怎样的?  发帖心情 Post By:2008/6/3 22:18:23

答:在数据库任务中以以下脚本可实现数据库的定时备份:

 


-- 异地备份

 

-- 第一步:使用net命令连接异地服务器
-- To allow advanced options to be changed.
EXEC sp_configure 'show advanced options', 1
GO
-- To update the currently configured value for advanced options.
RECONFIGURE
GO
-- To enable the feature.
EXEC sp_configure 'xp_cmdshell', 1
GO
-- To update the currently configured value for this feature.
RECONFIGURE
GO

EXEC xp_cmdshell 'net use \\192.168.1.6\d$\shq_bak password /user:administrator',no_output

-- 第二步:执行备份

declare @day int
set @day = datepart(weekday,getdate())
if (@day in (3,5,7)) begin
 backup database enjoy_shq to disk='\\192.168.1.6\d$\shq_bak\enjoy_shq01.bak' with init
end else if (@day in (2,4,6)) begin
 backup database enjoy_shq to disk='\\192.168.1.6\d$\shq_bak\enjoy_shq02.bak' with init
end else begin
 backup database enjoy_shq to disk='\\192.168.1.6\d$\shq_bak\enjoy_shq01.bak' with init
end


使用IE9无法添加附件的解决方法 支持(0中立(0反对(0回到顶部