Quick Answer
A broken log backup chain means one log backup starts at a log sequence number (LSN) later than the point where the previous one ended. Restore stops at that point with error 4305. Compare the first_lsn of every log backup with the last_lsn of the one before it in msdb to find the gap. Our test showed that a log backup sent to NUL is listed in msdb as a normal row, so a gap can hide in a complete looking history. Take a differential or a full backup to start a new chain.
Your restore stops with error 4305 and the log backup file in your hand is not damaged. One log backup between your full backup and that file is missing.
This guide gives you one query that finds the gap, the exact messages we got on SQL Server 2022 and the steps to start a clean chain.
What Is a Log Backup Chain and What Breaks It?
Microsoft states you restore a full or differential backup first and then every log backup made after it in chronological order. The same page states that when a log backup in the chain is lost or damaged, you can restore only the log backups before the missing one.
Every log backup stores two numbers. The first_lsn is where the backup starts and the last_lsn is where it ends. The chain is unbroken when the first_lsn of a log backup equals the last_lsn of the log backup before it.
| What breaks the chain | What we saw on our test instance |
|---|---|
| A log backup sent to NUL or a deleted file | msdb listed the NUL backup as a normal log backup. A restore from our files stopped with error 4305 |
| Recovery model switched from FULL to SIMPLE and back to FULL | BACKUP LOG failed with error 4214, BACKUP LOG cannot be performed because there is no current database backup |
| A failed log backup by third party software | Microsoft describes this case in KB 2966519, where the software advanced the backup LSN and then failed |
How Do You Find the Gap in msdb?
Execute this query. It lists every log backup of one database next to the end point of the log backup before it and marks a gap.
WITH l AS (
SELECT s.backup_set_id AS id, s.begins_log_chain AS bc, s.first_lsn, s.last_lsn,
LAG(s.last_lsn) OVER (ORDER BY s.backup_set_id) AS prev_last,
m.physical_device_name AS dev
FROM msdb.dbo.backupset AS s
JOIN msdb.dbo.backupmediafamily AS m ON m.media_set_id = s.media_set_id
WHERE s.database_name = N'YourDB' AND s.type = 'L')
SELECT id, bc, first_lsn, last_lsn, dev,
CASE WHEN prev_last IS NULL THEN 'first log'
WHEN first_lsn <> prev_last THEN 'GAP'
WHEN dev = 'NUL' THEN 'in msdb, file missing'
ELSE 'ok' END AS chain
FROM l ORDER BY id;
We built a test database with a full backup, a log backup, a log backup to NUL and a second log backup. Then we switched the recovery model to SIMPLE and back to FULL, took a differential backup and a last log backup. The query returned 4 rows.
| id | begins_log_chain | Device | chain result |
|---|---|---|---|
| 2 | 1 | lc1_l1.trn | first log |
| 3 | 0 | NUL | in msdb, file missing |
| 4 | 0 | lc1_l3.trn | ok |
| 6 | 1 | lc1_l5.trn | GAP |
Row 6 starts a new chain after the model switch. Row 3 is the problem for a restore because no file exists. The LSNs of row 3 match its neighbours, so only the device column gives it away.
Why Our First Query Showed a False Gap
Our first attempt compared the log backups with the backups of every type. The first log backup after a full backup starts before the full backup ends, so that query flagged a gap that did not exist. Filter on type L as the query above does.
What Does a Gap Look Like During a Restore?
We restored the full backup and the first log backup with NORECOVERY and then applied the log backup that follows the NUL backup. SQL Server returned this text.
Msg 4305, Level 16, State 1, Line 3
The log in this backup set begins at LSN 42000000028200001, which is too recent to apply to the database. An earlier log backup that includes LSN 42000000025800001 can be restored.
Msg 3013, Level 16, State 1, Line 3
RESTORE LOG is terminating abnormally.
The second LSN in the message is the first_lsn of the log backup you lack. Search the msdb query result for the row with that first_lsn. In our test it was row 3 and its device was NUL, so no file existed.
Error 4305 also appears when you restore two good files in the wrong order. Compare the LSNs before you hunt for a lost file. Our guide on SQL Server error 4305 explains the message in detail.
What Do These Queries Need on Your Server?
System Specifications
| Component | Requirement |
|---|---|
| Access to history | Select access to the backupset and backupmediafamily tables in msdb |
| History retention | The rows must still exist, so check your msdb cleanup job before you rely on them |
| Disk space | Free space for one new differential or full backup |
| Backup files | Every log backup file after your base backup on disk, tape or a share |
Software Specifications
| Item | Requirement |
|---|---|
| SQL Server version | SQL Server 2012 or later for the LAG function in the query |
| Recovery model | FULL or bulk logged, because SIMPLE has no log backups |
| Restore option | NORECOVERY on every restore step except the last |
| Tested on | SQL Server 2022 (RTM CU26) Express on Linux |
How Do You Fix a Broken Log Backup Chain?
Method #1: Find the Missing Log Backup File (Free, Best Case)
Use this method when the device column of the gap row shows a real path. The file can sit in a folder, on tape or in cloud storage that another backup tool manages.
- Copy the missing file to the same folder as the other log backups.
- Restore the full backup with NORECOVERY.
- Restore the log backups in LSN order, including the file you found.
- Restore the last log backup with RECOVERY.
When the device column shows NUL, no file exists. Move on to Method #2.
Method #2: Bridge the Gap With a Differential Backup (Free)
Use this method when the file is gone but the database is still online. A differential backup stores every change made since the last full backup, so it replaces the lost log backups for that period.
BACKUP DATABASE YourDB TO DISK = N'D:\Backups\YourDB_diff.bak' WITH DIFFERENTIAL;
BACKUP LOG YourDB TO DISK = N'D:\Backups\YourDB_log.trn';
In our test the differential backup worked after the recovery model went from SIMPLE to FULL. The next log backup succeeded and msdb marked it with begins_log_chain 1, which means a new chain started.
Restore the full backup first, then the differential backup and then the new log backups. You cannot restore to a point inside the gap, only to the time of the differential backup or later.
Method #3: Start a New Chain With a Full Backup (Free)
Use this method when no usable full backup exists. Our log backup returned error 4214 after a model switch until a current backup existed.
BACKUP DATABASE YourDB TO DISK = N'D:\Backups\YourDB_full.bak' WITH CHECKSUM;
BACKUP LOG YourDB TO DISK = N'D:\Backups\YourDB_log.trn';
Our guide on tail log backup in SQL Server shows how to save the last log records before you restore over a damaged database.
How Do You Stop the Chain From Breaking Again?
- Do not send a log backup to NUL. Our test shows msdb records it as a normal backup, so nobody sees the gap until a restore fails.
- Take a backup right after a switch from SIMPLE to FULL. Error 4214 in our test appeared when we skipped it.
- Execute the gap query every week. A gap you find on Monday costs a differential backup. A gap you find during an outage costs data.
- Restore a copy every month. Our guide on SQL Server point in time restore lists the steps.
What Do People Ask About a Broken Log Backup Chain?
How Do You Check if the Log Backup Chain Is Broken?
Compare the first_lsn of every log backup with the last_lsn of the previous one in msdb. The query in this guide does it and also shows the device of every backup.
Does a Log Backup to NUL Break the Log Chain?
It breaks your restore. In our test msdb listed the NUL backup with continuous LSNs, but no file existed, so the restore stopped with error 4305.
Does Switching to SIMPLE Recovery Break the Log Chain?
Yes. Microsoft states a new chain starts when the model switches from SIMPLE to FULL or bulk logged. Our log backup failed with error 4214 until we took a differential backup.
What Does begins_log_chain Mean in msdb?
Microsoft states the value 1 marks the first backup in a continuous chain of log backups. A chain starts with the first log backup after database creation or after a switch from SIMPLE to FULL or bulk logged.
Can You Restore Past a Missing Log Backup?
No. Microsoft states you can restore only the log backups before the missing one. A differential backup taken after the gap gives you a new restore base.
About this guide
We checked this guide against Microsoft documentation on 3 Dec 2026. We executed every query and backup statement of this guide on SQL Server 2022 (RTM CU26) Express on Linux.
Microsoft documents the restore order on its apply transaction log backups page and the history columns on its backupset page.
