SQL Server 2005异地备份 - 转-已验证
2009-03-15 15:57
281 查看
本方案采用备份至本地然后copy到文件服务器的方法。
SQL server 2005打了sp2的补丁后好像存储过程xp_cmdshell是不能直接用的显示高级选项(仅需执行一次)
EXEC sp_configure 'show advanced options', 1 GO RECONFIGURE GO* |
EXEC sp_configure 'xp_cmdshell', 1 GO RECONFIGURE GO |
declare @string nvarchar(200) set @string = 'net use z: \\192.168.1.2\D$\db_backup "123456" /user:fileserver\administrator' exec master..xp_cmdshell @string |
备份数据库至本地
declare @date datetime set @date = GetDate() declare @str nvarchar(100) set @str = 'd:\mydb'+ convert(nvarchar(12), @date, 112) +'.bak' backup database mydb to disk=@str with init |
拷贝到文件服务器
declare @str1 nvarchar(100) set @str1 = 'copy '+ @str +' z:' exec master..xp_cmdshell @str1 |
exec master..xp_cmdshell 'net use z: /delete' declare @str2 nvarchar(100) set @str2 = 'del '+@str+'' exec master..xp_cmdshell @str2 |
EXEC sp_configure 'xp_cmdshell', 0 GO RECONFIGURE GO |
相关文章推荐
- SQL Server 2005异地备份
- SQL Server 2005异地备份
- SQL Server 2005异地备份
- SQL Server 2005数据库的自动定时备份及异地备份
- SQL Server 2005中的备份和恢复增强
- SQL SERVER 2005/2008和2000的自动备份
- (转)用Sql Server 2000的数据库备份还原到Sql Server 2005中的数据库
- SQL Server 2005数据库定期备份
- Sql Server 2000数据库备份文件还原成Sql Server 2005
- SQL Server 2005 自动备份数据库 维护计划实现数据库定时自动备份
- sql server 2000数据库备份文件还原成sql server 2005
- 在SQL Server 2005数据库中实现自动备份
- 图解SQL Server 2000和SQL Server 2005定期自动备份数据库(SQL Server 2000篇)
- 远程备份SQL Server 2005数据库
- SQL Server 2005使用作业实现定时备份任务和删除指定天数前的备份文件
- SQL Server 2005 如何自动备份数据库
- 修改SQL Server 2005/2008 用户数据库文件默认路径和默认备份路径
- 改变SQL Server 2005 Express 的身份验证方式
- SQL Server: 2005/2014 普通备份与压缩备份对比
- SQL SERVER 2005如何建立自动备份的维护计划