Either error message may be displayed (too early or too late):
“The log in this backup set terminates at LSN 45000000038500037,which is too early to apply to the database.” or “The log in this backup set begins at LSN 45000000002500001, which is too late to apply to the database. An earlier log backup that includes LSN 45000000015900001 can be restored.”
This Microsoft SQL Server error message indicates that the LSN numbers included in the restore are out of sequence from transactions previously restored.
Retrieve the backup file information as well as the restore information from the following command on the server restoring the database:
use msdb
SELECT DISTINCT TOP 20
s1.type,
s1.backup_start_date,
s1.first_lsn,
s1.last_lsn,s1.checkpoint_lsn,
s1.database_backup_lsn
--s2.physical_device_name
from msdb..backupset s1 inner join msdb..backupmediafamily s2
on s1.media_set_id = s2.media_set_id
where s1.database_name ='Northwind'
and s1.backup_start_date >= '6/03/2008 04:41:25 AM'
-- You will need to change to the database you are querying
and s1.type in('D','L','I') -- sl.type in ('D','L') means full or Transaction Log backups (if 'I', Differential backups) or ('F' for File Group, 'G' for File Group Differential)
--and s1.backup_start_date >= (select max(backup_start_date) from msdb..backupset where database_name ='Northwind' and type ='D')
order by s1.backup_start_date desc
RestoreInfoScript:
SELECT s1.restore_type
, s2.first_lsn
, s2.last_lsn
, s2.checkpoint_lsn
, s2.database_backup_lsn
, s1.restore_date
, s2.backup_start_date
, s1.destination_database_name
, s1.backup_set_id
, s3.physical_device_name
FROM msdb..restorehistory as s1 INNER JOIN msdb..backupset as s2
ON s1.backup_set_id = s2.backup_set_id
INNER JOIN msdb..backupmediafamily as s3
ON s2.media_set_id = s3.media_set_id
where
s1.destination_database_name ='' -- the database restored
and s1.restore_type in('D','L','I') -- sl.type in ('D','L') means full or Transaction Log backups (if 'I', Differential backups)
order by s1.restore_date desc
Query the backup information from the server that the backup came from:
select
s1.type,
s1.backup_start_date,
s1.backup_finish_date,
s1.first_lsn,
s1.last_lsn,s1.checkpoint_lsn,
s1.database_backup_lsn,
s2.physical_device_name
from msdb..backupset s1 inner join msdb..backupmediafamily s2
on s1.media_set_id = s2.media_set_id
where s1.database_name ='' -- Backup Database
and s1.type in('D','L','I') -- sl.type in ('D','L') means full or Transaction Log backups (if 'I', Differential backups)
and s1.backup_start_date >= (select max(backup_start_date) from msdb..backupset where database_name ='' and type ='D') -- change to the Backup Database
order by s1.backup_start_date asc
Compare the output, to determine which file should be the next to be restored.
© ALL RIGHTS RESERVED. Terms of Use Privacy Cookie Preference Center