Skip to content

Est. 2011ยทMicrosoft Partner 7033487ยทDelivery under 3 minยทSupport 7 days a week

Your vault is empty.

Free Fix 4305

Errors 4305 and 4326: Log Backups Out of Sequence in a Restore Chain

12 min read Updated October 4, 2026 SQL Server

Fix it now

A log backup does not fit where you are trying to apply it. 4305 means the file begins at an LSN too recent to apply, so something between the two is missing. 4326 means it ends at an LSN too early, so it has already been applied. Neither indicates damage: what you have is an ordering problem in the sequence you are feeding the engine.

Run this on the instance that took the backups, to see the real chain

SELECT bs.type, bs.backup_start_date, bs.backup_finish_date,
       bs.first_lsn, bs.last_lsn, bs.database_backup_lsn,
       bmf.physical_device_name
FROM   msdb.dbo.backupset bs
JOIN   msdb.dbo.backupmediafamily bmf ON bmf.media_set_id = bs.media_set_id
WHERE  bs.database_name = N'MyDb'
ORDER BY bs.backup_finish_date;
  1. Confirm the database is still mid-restore: SELECT name, state_desc FROM sys.databases WHERE name = N'MyDb'; should read RESTORING.
  2. Read the type column. D is a full backup, I a differential, L a log, F a file or filegroup backup, G a differential file backup, P a partial and Q a differential partial.
  3. Restore the full backup WITH NORECOVERY, then the most recent differential based on it, also WITH NORECOVERY.
  4. Apply every log backup taken after that differential, in order, each WITH NORECOVERY.
  5. Use WITH RECOVERY only on the last statement, or issue RESTORE DATABASE [MyDb] WITH RECOVERY; on its own at the end.

Both messages name the LSN they want. 4305 tells you an earlier log backup including a specific LSN can be restored; 4326 tells you a more recent one can. Read the number rather than guessing which file is next.

If the sequence completes and the database comes online, you are done. If a file is genuinely missing, the next section explains how far you can still get.

Why it happens

Every change written to the transaction log gets a log sequence number, and those numbers only ever increase. A log backup copies a contiguous range of them and records its first and last LSN in its header, which is what you see in the first_lsn and last_lsn columns of msdb.dbo.backupset. When you restore, the engine knows exactly which LSN the database has reached and will only accept a log backup whose range begins there.

That single rule produces both errors, and both messages are more helpful than they look. 4305 says the log in this backup set begins at an LSN which is too recent to apply, and then names an earlier LSN that can be restored. 4326 says the log terminates at an LSN too early to apply, and names a more recent one. Neither is a complaint about the file: they are directions to the right one.

Differentials work differently and this is where sequences get tangled. Each differential is tied to a specific full backup through its database_backup_lsn, which records the LSN of the most recent full backup it is based on. Restoring a differential onto a different base fails for the same family of reasons, and the column that tells you which base it needs is in the same query.

The chain is broken by things done at the source, not at the restore. Switching to simple recovery ends it. So does a second job, a third-party backup product or an ad-hoc log backup taken to somewhere you do not know about, because each of those truncates the log and carries the next range away with it. A copy-only log backup is the exception: it reads the log without truncating it and leaves the sequence intact, which is why any ad-hoc log backup should carry COPY_ONLY.

Files are being applied out of order, or one is missing

You have this one if 4305 on a file you expected to work, and the timestamps of your files show a gap.

  1. List the chain from the source instance with the query above, ordered by backup_finish_date, and read the type and LSN columns.
  2. Check each file you hold against that list and identify exactly which backup is absent.
  3. Compare the LSN named in the 4305 message with the last_lsn values in the list. The file you need is the one whose range contains it.
  4. If the missing file exists on the backup target or on tape, retrieve it and apply it in place. If it is gone, restore up to the last file before the gap and recover there.

Everything after the gap is unreachable through the log chain. The alternative is a later full backup, if one exists.

The chain was broken at the source

You have this one if There is no file covering the gap and there never was, or the database spent time in simple recovery.

  1. Check the current model: SELECT name, recovery_model_desc FROM sys.databases;
  2. Ask whether another tool or job also backs up this log. Two schedulers taking log backups will each hold half the chain.
  3. Standardise on one log backup schedule, and make any ad-hoc log backup WITH COPY_ONLY so it does not truncate.
  4. Take a fresh full backup now, so a clean chain starts from a known point.

Moving a database to simple recovery and back does not resume the old chain. A new full backup is required before log backups mean anything again.

The database was recovered too early

You have this one if 3117, and the database shows as ONLINE rather than RESTORING while you still have logs to apply.

  1. Accept that the sequence has to start again from the full backup. There is no way back into a restoring state.
  2. Restore the full backup WITH NORECOVERY, then the differential, then the logs.
  3. Script the whole sequence before running it, so no step defaults to RECOVERY by accident.
  4. In Management Studio, check the restore dialog is not set to leave the database ready to use.

A previous restore of one file was interrupted

You have this one if 4319, naming a specific file.

  1. Read the message: it offers two options. Restore the backup set that was interrupted, or restart the restore sequence.
  2. Try the interrupted file again first. It is the cheaper of the two.
  3. If that fails, restart from the full backup rather than trying to resume from an uncertain point.

The tail of the live log has not been backed up

You have this one if 3159 when restoring over a database that is still online and in full recovery.

  1. Capture the work since the last log backup: BACKUP LOG [MyDb] TO DISK = N'D:\bk\MyDb_tail.trn' WITH NORECOVERY;
  2. Restore your sequence, then apply that tail file last to reach the moment of failure.
  3. Only if you are certain the recent changes are worthless, use WITH REPLACE or WITH STOPAT to skip the tail backup. The message names both.

WITH NORECOVERY on a tail-log backup leaves the database in restoring state, which is exactly what you want when you are about to restore over it.

Full reference

Which message you have and what it wants

Error What the restore is telling you
4305 The log begins at an LSN too recent to apply. An earlier log backup including the named LSN can be restored
4326 The log terminates at an LSN too early to apply. A more recent log backup including the named LSN can be restored
4335 The specified STOPAT time is too early. All or part of the database is already rolled forward beyond that point
3159 The tail of the log has not been backed up. Use BACKUP LOG WITH NORECOVERY, or WITH REPLACE or WITH STOPAT to overwrite it
3117 The log or differential backup cannot be restored because no files are ready to roll forward
4319 A previous restore was interrupted on this file. Restore that backup set again, or restart the sequence

Reading msdb.dbo.backupset without guessing

Column What it tells you
type D full, I differential database, L log, F file or filegroup, G differential file, P partial, Q differential partial
first_lsn The log sequence number of the first or oldest log record in the backup set
last_lsn The log sequence number of the next log record after the backup set
database_backup_lsn The LSN of the most recent full backup. This is what ties a differential to its base
backup_finish_date When it completed. Order by this, not by file name

Reading the type column is what stops you trying to apply a differential as though it were a log backup, which is the most common way a chain gets misread. Reading database_backup_lsn is what stops you applying a differential to the wrong full backup.

Finding the last restorable point

  1. Build the ordered list from the source instance with the query in the fix section.
  2. Walk forward from your full backup, checking that each file’s first_lsn continues from the previous file’s last_lsn.
  3. The first place that does not continue is the gap.
  4. The backup_finish_date of the last file before the gap is as far as you can reach in time.
  5. Restore up to that file, then issue RESTORE DATABASE WITH RECOVERY, and take a fresh full backup immediately.

Why the chain gets broken, and how to keep it

  • Two schedulers taking log backups will each hold half the chain and neither will be complete. Standardise on one.
  • Any ad-hoc log backup should carry COPY_ONLY, which reads the log without truncating it.
  • A switch to simple recovery ends the chain immediately, and switching back does not resume it. Take a full backup afterwards.
  • Differentials do not truncate the log and do not affect the chain. Only log backups and a recovery model change do.
  • A third-party backup product taking log backups counts as a second scheduler. Find out before you need the chain, not during a restore.

Point in time, and the STOPAT trap

4335 is the one that catches people out during a point-in-time restore. It means the STOPAT value you gave is behind where the restore has already rolled forward, so there is nothing left to stop at. The fix is not to change the STOPAT value repeatedly; it is to start the sequence again from the full backup and apply the log backups with the STOPAT clause on each of them, so the roll-forward stops where you meant it to the first time.

Every code this article covers

Code What it points at Source
4305 The log in this backup set begins at an LSN which is too recent to apply to the database. An earlier log backup including the named LSN can be restored Microsoft Learn
4326 The log in this backup set terminates at an LSN which is too early to apply. A more recent log backup including the named LSN can be restored Microsoft Learn
4335 The specified STOPAT time is too early. All or part of the database is already rolled forward beyond that point Microsoft Learn
3159 The tail of the log has not been backed up. Use BACKUP LOG WITH NORECOVERY to keep it, or WITH REPLACE or WITH STOPAT to overwrite it Microsoft Learn
3117 The log or differential backup cannot be restored because no files are ready to roll forward Microsoft Learn
4319 A previous restore operation was interrupted and did not complete on this file. Either restore the backup set that was interrupted, or restart the restore sequence Microsoft Learn

Confirm the fix worked

  1. Confirm the database finished the sequence: SELECT name, state_desc FROM sys.databases WHERE name = N'MyDb'; should read ONLINE.
  2. Check what was applied and in which order: SELECT restore_date, restore_type, backup_set_id FROM msdb.dbo.restorehistory WHERE destination_database_name = N'MyDb' ORDER BY restore_date;
  3. Query a table with recent activity and confirm the data reaches the point in time you expected.
  4. Take a fresh full backup immediately, so the recovered database has its own clean chain.
  5. Confirm only one schedule is taking log backups from now on.

Questions people ask about this

Does fixing this cost anything?

Nothing at all. Point-in-time restore, log backups and the whole restore sequence are core engine functionality in every edition. This is a sequencing problem and the only resource it consumes is your time.

Can I skip a missing log backup and carry on with the later ones?

No. The chain has no gaps by design, because the engine cannot invent transactions it never received. You can roll forward to the last file before the gap, or restore the whole database from a later full backup if one exists.

How do I find the last restorable point?

Read the last_lsn and backup_finish_date of the last log backup you hold that still connects to the chain. That timestamp is as far as you can reach.

Do differential backups break the log chain?

No. Differentials and log backups are independent, and a differential neither truncates the log nor affects the sequence. Only a log backup, or a switch to simple recovery, changes the chain.

What does 4319 want me to do?

Its message offers two options and both are valid: restore the backup set that was interrupted, or restart the restore sequence. Try the interrupted file again first, because restarting from the full backup is the expensive option.

Related error codes

Was this article helpful?

Your feedback helps us improve our documentation.

Related articles

Free Fix Error 3201: Cannot Open Backup Device – Permissions and Path Problems Free Fix Error 20011 and 20084: Replication Agent Failures and Rejected Subscriptions Free Fix Error 208: Invalid Object Name – Schema, Database Context and Collation License Error Error 41131: Failed to Bring the Availability Group Online
โ† Back to Knowledge Base