ITPub博客

首页 > Linux操作系统 > Linux操作系统 > SQLSERVER 备份与恢复

SQLSERVER 备份与恢复

原创 Linux操作系统 作者:gullvip 时间:2010-12-22 13:26:59 0 删除 编辑

--完全备份

DECLARE @strPath NVARCHAR(200)
set @strPath = convert(NVARCHAR(19),getdate(),120)
set @strPath = REPLACE(@strPath, ':' , '.')
set @strPath = 'E:\datebak\' + 'drpdb_full_'+@strPath + '.bak'
BACKUP DATABASE [drpdb] TO DISK = @strPath WITH NOINIT , NOUNLOAD , NOSKIP , STATS = 10, NOFORMAT

 

--差异备份

DECLARE @strPath NVARCHAR(200)
set @strPath = convert(NVARCHAR(19),getdate(),120)
set @strPath = REPLACE(@strPath, ':' , '.')
set @strPath = 'E:\datebak\' + 'drpdb_incrment_'+@strPath + '.bak'
BACKUP DATABASE [drpdb] TO DISK = @strPath with format,differential

 

--恢复

restore database drpdb from disk='E:\backup\drpdb_full_2010-09-26 02.00.00.bak'  with norecovery, replace 

restore database drpdb from disk='E:\backup\drpdb_incrment_2010-09-30 02.00.00.bak'  with recovery

 

restore headeronly from bak1
restore database d1 from bak1 with file=2         --从完全备份中恢复
--
--------------------------------------------------------------------
restore headeronly from bak2              --从差异备份中恢复
restore database d2 from bak2 with file=1,norecovery   
restore database d2 from bak2 with file=5,recovery
----------------------------------------------------------------------
restore headeronly from bak3              --从日志备份中恢复
restore database d3 from bak3 with file=1,norecovery
restore log    d3 from bak3 with file=2,norecovery
restore log    d3 from bak3 with file=3,norecovery
restore log    d3 from bak3 with file=4,norecovery
restore log    d3 from bak3 with file=5,recovery

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/16313359/viewspace-682345/,如需转载,请注明出处,否则将追究法律责任。

下一篇: LEFT JOIN 优化问题
请登录后发表评论 登录
全部评论

注册时间:2010-12-20

  • 博文量
    34
  • 访问量
    67316