首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

复原数据库时显示:该LSN 太晚,无法应用到数据库

2013-06-26 
还原数据库时显示:该LSN 太晚,无法应用到数据库大家好,我对数据库test进行了完整备份之后删除了table1表的

还原数据库时显示:该LSN 太晚,无法应用到数据库
大家好,我对数据库test进行了完整备份之后删除了table1表的一条记录,然后再进行事务日志备份,可还原的时候提示说该LSN 太晚,无法应用到数据库,请问大家应该如何安排这个备份呢?操作代码和异常代码如下:

backup db test to disk='d:\test_data.bak'
delete from table1 where a=3
select dt=getdate() into #
backup log test to disk='d:\test_log.bak'
restore database test from disk='d:\test_data.bak' with replace,NORECOVERY
DECLARE @dt datetime
select @dt=dateadd(ms,-40,dt) from #
restore log test from disk='d:\test_log.bak' with recovery,stopat=@dt



消息 4305,级别 16,状态 1,第 3 行
此备份集中的日志开始于 LSN 18000000022900001,该 LSN 太晚,无法应用到数据库。可以还原包含 LSN 18000000022300001 的较早的日志备份。
消息 3013,级别 16,状态 1,第 3 行
RESTORE LOG 正在异常终止。

顺便问一下,我第一次做完整备份,接下来做事务日志备份,第一次事务日志备份可否选择截断事务日志?
[解决办法]


backup database test to disk='d:\test_data.bak'
delete from test.dbo.a where id=10

select dt=getdate() into #
backup log test to disk='d:\test_log2.bak'
restore database test1 from disk='d:\test_data.bak' with replace,NORECOVERY,
  MOVE 'test' TO 
'C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\Data\NewAdvWorks.mdf', 
      MOVE 'test_log' 
TO 'C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\Data\NewAdvWorks.ldf'



DECLARE @dt datetime
select @dt=dateadd(ms,-40,dt) from #
restore log test1 from disk='d:\test_log2.bak' with recovery,stopat=@dt


我的这个测试没有问题。


select * from backupset

--如果有log写入那么这一档的last_lsn 应该为下一档的first_lsn,自己看一下中间还有没有其他备份,
或lsn是否连续。还是两档log备在了同一个文件下(需要join一下备份媒体表)。
/*
first_lsnlast_lsncheckpoint_lsndatabase_backup_lsndatabase_creation_datebackup_start_datebackup_finish_datetype
30000000000702000373000000000072100001300000000007020003702013-01-15 14:55:06.0002013-06-09 15:43:32.0002013-06-09 15:43:33.000D
30000000000702000373000000000073100001300000000007020003730000000000702000372013-01-15 14:55:06.0002013-06-09 15:43:34.0002013-06-09 15:43:34.000L


30000000000734000473000000000075300001300000000007340004730000000000702000372013-01-15 14:55:06.0002013-06-09 15:44:41.0002013-06-09 15:44:42.000D
30000000000765000473000000000078400001300000000007650004730000000000734000472013-01-15 14:55:06.0002013-06-09 15:45:07.0002013-06-09 15:45:08.000D
30000000000731000013000000000079100001300000000007650004730000000000765000472013-01-15 14:55:06.0002013-06-09 15:45:08.0002013-06-09 15:45:08.000L
30000000000799000433000000000081700001300000000007990004330000000000765000472013-01-15 14:55:06.0002013-06-09 15:46:50.0002013-06-09 15:46:51.000D
30000000000784000013000000000082400001300000000007990004330000000000799000432013-01-15 14:55:06.0002013-06-09 15:46:51.0002013-06-09 15:46:51.000L
30000000000826000373000000000084200001300000000008260003730000000000799000432013-01-15 14:55:06.0002013-06-09 15:49:59.0002013-06-09 15:50:00.000D
30000000000824000013000000000084900001300000000008260003730000000000826000372013-01-15 14:55:06.0002013-06-09 15:50:00.0002013-06-09 15:50:00.000L
30000000000851000373000000000086700001300000000008510003730000000000826000372013-01-15 14:55:06.0002013-06-09 15:51:06.0002013-06-09 15:51:07.000D
30000000000849000013000000000087400001300000000008510003730000000000851000372013-01-15 14:55:06.0002013-06-09 15:51:07.0002013-06-09 15:51:07.000L
30000000000874000013000000000087600001300000000008510003730000000000851000372013-01-15 14:55:06.0002013-06-09 15:52:22.0002013-06-09 15:52:22.000L
30000000000879000473000000000089800001300000000008790004730000000000851000372013-01-15 14:55:06.0002013-06-09 15:53:27.0002013-06-09 15:53:28.000D
30000000000876000013000000000090700001300000000008790004730000000000879000472013-01-15 14:55:06.0002013-06-09 15:53:28.0002013-06-09 15:53:28.000L
*/

热点排行