Rss & SiteMap

昂捷论坛 http://www.enjoyit.com.cn

中国零售业界精英论坛!
共2 条记录, 每页显示 15 条, 页签: [1]
[浏览完整版]

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

1楼
飞絮 发表于: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

共2 条记录, 每页显示 15 条, 页签: [1]

Copyright © 2006-2010 EnjoyIT.com.cn
网友言论或观点与昂捷公司无关!涉及版权/著作权问题请与发帖者直接联系
Powered By Dvbbs Version 8.2.0
Processed in 0.14063 s, 2 queries.