SQL Server 2005异地备份
2008-07-21 14:42
225 查看
前几天做了数据库镜像,现在也要来做做数据库的备份。本方案采用备份至本地然后copy到文件服务器的方法。
SQL server 2005打了sp2的补丁后好像存储过程xp_cmdshell是不能直接用的
显示高级选项(仅需执行一次)
允许执行xp_cmdshell
添加映射驱动器
其中192.168.1.2为文件服务器的地址,db_backup为该服务器的共享文件夹,fileserver为机器名,administrator 123456 分别为共享时设置的用户名密码。
备份数据库至本地
With init为覆盖同名文件(本例设计为1天执行一次,不会出现覆盖的情况)。
拷贝到文件服务器
删除映射以及本地备份
7关闭允许执行cmdshell
建立sql server 作业执行步骤2-7,成功备份!
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作业备份报错解决办法
- SQL Server 2005定时备份维护操作步骤定时备份维护操作步骤定时备份维护操作步骤定时备份维护操作步骤
- 【Vegas原创】SQL Server 2005部署备份任务
- SQL SERVER 2005如何建立自动备份的维护计划
- 【转】SQL Server 2005数据库定期备份和删除历史备份记录
- SQL Server 2005数据库定期备份
- SQL Server 2005“备份集中的数据库备份与现有的数据库不同”解决方法
- SQL SERVER 2005如何建立自动备份的维护计划
- Sql Server 2005数据库备份问题
- SQL Server 2005使用命名的备份设备
- 轻松实现SQL Server异地备份
- SQL Server 2005/2008备份数据库时提示“无法打开备份设备”
- sql server 2005 的卸载和自动备份 说明
- 配置sql server 2005, 实现自动备份
- Sql Server 2005 数据库备份还原后出现“受限制用户”问题的解决[转]