If the magazine's re-established CONTINUE_AFTER_ERROR (or STOP_ON_ERROR)RESTORE LOG [ka]
FROM DISK = N'D:\Tail.bak'
WITH FILE = 1, CONTINUE_AFTER_ERROR, NORECOVERY
GO
ended with a mistake that cannot be implementedRESTORE DATABASE [ka]
WITH RECOVERY
GO
You can try to get back to something. LSN in a magazine (maximum possible) RESTORE LOG It doesn't make any mistakes.To this end, we read the headlines of the OBD backup and magazine.RESTORE HEADERONLY FROM DISK = N'C:\2016.Bak'
RESTORE HEADERONLY FROM DISK = N'D:\Tail.bak'
where poles are measured FirstLSN and LastLSN (We're convinced that the LSN chain is not broken, and there is indeed more information in the magazine).Let's say we got:C:\2016.Bak
FirstLSN LastLSN
----------------- -----------------
64000000005600195 64000000017600001
D:\Tail.bak
FirstLSN LastLSN
64000000005600195 66000000025600001
Compare LSN: 6,4000005600195 PER= 64000017600001 ·01 - OK.Importance LastLSN from OBD heading (equivalent 64000017600001(c) Transfer from the decimal place to the binary (see annex). https://support.microsoft.com/en-us/kb/886839 , function fn_convertnumericlsntobinaryreceived 00000040:000B0:0001♪Now with help. sys.fn_dump_dblog Read the sequence of LSN from the league dam (possible only to filter out transactions) Operation = 'LOP_COMMIT_XACT'select [Current LSN]
from sys.fn_dump_dblog(
NULL, NULL, N'DISK', 1, N'D:\Tail.bak',
default, default, default, default, default, default, default,
default, default, default, default, default, default, default,
default, default, default, default, default, default, default,
default, default, default, default, default, default, default,
default, default, default, default, default, default, default,
default, default, default, default, default, default, default,
default, default, default, default, default, default, default,
default, default, default, default, default, default, default,
default, default, default, default, default, default, default)
where Operation = 'LOP_COMMIT_XACT';
Let's say we got the next list:Current LSN
00000040:000000a0:0002
00000040:000000b8:0001 <-- сначала восстанавливаем журнал к этой отметке
00000040:000000c8:000b <-- потом к этой
00000040:000000d0:000a <-- ...
00000040:000000d8:000a <-- ...
00000040:000000e0:000a <-- ...
00000040:000000e8:000a <-- ...
00000040:000000f0:000b <-- ...
00000040:000000f8:0010 <-- ...
00000040:000000f8:0021 <-- и т.д, пока не встретим ошибку
00000040:000000f8:0027 <-- ERROR
00000040:00000110:0017
00000040:00000130:001b
00000040:00000130:001d
00000040:00000140:000a
Reinitiate recovery:RESTORE DATABASE [ka]
FROM DISK = N'D:\2016.bak'
WITH NORECOVERY, REPLACE
GO
Now we take the first LSN value from the list, which should be later than LastLSN Bachepe of OBD (later than 00000040:000000B0:0001and do RESTORE LOG to this mark:RESTORE LOG [ka]
FROM DISK = N'D:\Tail.bak'
WITH FILE = 1, STOPATMARK = 'lsn:0x00000040:000000b8:0001', NORECOVERY
GO
If the operation went wrong, we repeat the same for the next mark, etc. until we get to the mark, which will cause a mistake.If there is much mark, a dichotomy search can be used, given, however, that only sufficient progress can be made. RESTORE LOG to the new mark, but if it is necessary to return back, the recovery chain needs to be re-examined (RESTORE DATABASE ... WITH REPLACE ...Then RESTORE LOG ... to the right mark.Once the last single error has been determined, re-establish the OBD and log to that mark:RESTORE DATABASE [ka]
FROM DISK = N'D:\2016.bak'
WITH NORECOVERY, REPLACE
GO
RESTORE LOG [ka]
FROM DISK = N'D:\Tail.bak'
WITH STOPATMARK = 'lsn:0x00000040:000000f8:0021', NORECOVERY
GO
After which the reconstruction is completed:RESTORE DATABASE [ka]
WITH RECOVERY
GO