Fix SQL Server Error 3159 (Tail Log Backup Needed)
SQL Server error 3159 stops a restore because the transaction log holds work that no backup has captured. SQL Server refuses to start the restore because the restore would overwrite that work.
This guide explains how to read the message and gives four fixes in the order that protects your data best.
Quick SummarySQL Server error 3159 means a restore would overwrite log records that no backup holds. Take a tail log backup with BACKUP LOG WITH NORECOVERY first. Use NO_TRUNCATE for an offline database and CONTINUE_AFTER_ERROR for a damaged one. Restore to a point in time when an earlier log backup holds your recovery point. Use WITH REPLACE only when you can lose the work in the log.
What Does SQL Server Error 3159 Say About Your Log?
According to the Microsoft page for error 3159, SQL Server requires a tail log backup before a restore under the full or bulk logged recovery model. The tail of the log is the part of the log that no log backup holds.
Msg 3159, Level 16, State 1, Line 1
The tail of the log for the database "OrdersDB" has not been backed up. Use BACKUP LOG WITH NORECOVERY to back up the log if it contains work that you do not want to lose. Use the WITH REPLACE or WITH STOPAT clause of the RESTORE statement to just overwrite the contents of the log.
Msg 3013, Level 16, State 1, Line 1
RESTORE DATABASE is terminating abnormally.
The Microsoft article on tail log backups states that a tail log backup prevents work loss and keeps the log chain intact. Error 3159 protects the live database and says nothing about the quality of your backup files.
Do You Know?Microsoft states that a tail log backup is not needed when your recovery point sits inside an earlier log backup. It is also not needed when you move or overwrite a database and want no point after the last backup. Follow fix SQL Server error 3201 when the backup device itself fails to open.
How to Check Whether You Need a Tail Log Backup?
Check the recovery model and the time of the last log backup before you restore again. The first query shows the recovery model and the state of the database.
SELECT name, recovery_model_desc, state_desc
FROM sys.databases
WHERE name = N'OrdersDB';
Expected output shows FULL or BULK_LOGGED for a database that raises error 3159. Microsoft limits tail log backups to these two recovery models. The next query shows when the last log backup finished.
SELECT TOP (1) backup_finish_date
FROM msdb.dbo.backupset
WHERE database_name = N'OrdersDB' AND type = 'L'
ORDER BY backup_finish_date DESC;
Compare that time with the moment you need as your recovery point. Every transaction after that time exists only in the live log.
| What you need | State of the database | Start with |
|---|---|---|
| Every transaction up to now | Online | Method 1 |
| Every transaction up to now | Offline or fails to start | Method 2 with NO_TRUNCATE |
| Every transaction up to now | Damaged | Method 2 with CONTINUE_AFTER_ERROR |
| A time inside your existing log backups | Any state | Method 3 |
| A clean overwrite and the log work has no value | Any state | Method 4 |
How to Fix SQL Server Error 3159?
Every example uses the database OrdersDB and the folder D:\Backup. Replace the names and the paths with your own values.
Method 1: Take a Tail Log Backup With NORECOVERY
Use this method when the database is online and you need every transaction. Microsoft states that an online database needs the NORECOVERY option for this backup. NORECOVERY leaves the database in the restoring state so nothing changes after the backup.
BACKUP LOG [OrdersDB]
TO DISK = N'D:\Backup\OrdersDB_tail.trn'
WITH NORECOVERY;
Restore your full backup first and then every log backup in order. Restore the tail log backup last and recover the database in that step. Microsoft notes that exclusive access during the restore can require single user mode.
RESTORE DATABASE [OrdersDB] FROM DISK = N'D:\Backup\OrdersDB_full.bak' WITH NORECOVERY;
RESTORE LOG [OrdersDB] FROM DISK = N'D:\Backup\OrdersDB_log1.trn' WITH NORECOVERY;
RESTORE LOG [OrdersDB] FROM DISK = N'D:\Backup\OrdersDB_tail.trn' WITH RECOVERY;
Follow restore database with NORECOVERY for the full sequence with differential backups.
Method 2: Take a Tail Log Backup of an Offline or Damaged Database
Use this method when the database is offline or damaged. Microsoft states that an offline database that fails to start needs NO_TRUNCATE because no transaction can occur. NO_TRUNCATE works like a copy only log backup.
BACKUP LOG [OrdersDB]
TO DISK = N'D:\Backup\OrdersDB_tail.trn'
WITH NO_TRUNCATE;
Use CONTINUE_AFTER_ERROR for a damaged database. Microsoft limits this option to three conditions. The log files must be undamaged, the database must be in a state that supports tail log backups and the database must hold no bulk logged changes.
BACKUP LOG [OrdersDB]
TO DISK = N'D:\Backup\OrdersDB_tail.trn'
WITH CONTINUE_AFTER_ERROR;
The backup carries incomplete metadata in this case. The captured log stays complete and usable. Check the flag with RESTORE HEADERONLY and look for HasIncompleteMetadata set to 1.
RESTORE HEADERONLY FROM DISK = N'D:\Backup\OrdersDB_tail.trn';
Microsoft states that every transaction committed after your latest log backup is lost when the tail log backup fails. Move to Method 3 or Method 4 in that case.
Method 3: Restore to a Point in Time With STOPAT
Use this method when your recovery point sits inside the log backups you already hold. Microsoft states that the STOPAT clause applies to RESTORE DATABASE and RESTORE LOG under the full and bulk logged models. On RESTORE DATABASE the clause works as a check. On RESTORE LOG the clause sets the recovery point.
RESTORE DATABASE [OrdersDB] FROM DISK = N'D:\Backup\OrdersDB_full.bak'
WITH NORECOVERY, STOPAT = N'2026-11-30T09:30:00';
RESTORE LOG [OrdersDB] FROM DISK = N'D:\Backup\OrdersDB_log1.trn'
WITH NORECOVERY, STOPAT = N'2026-11-30T09:30:00';
RESTORE LOG [OrdersDB] FROM DISK = N'D:\Backup\OrdersDB_log2.trn'
WITH RECOVERY, STOPAT = N'2026-11-30T09:30:00';
Every RESTORE LOG statement in the sequence needs the same STOPAT time. SQL Server leaves the database unrecovered when the time falls after your last log backup. Check the time against the backupset query from the section above.
Method 4: Restore With REPLACE and Drop the Log Work
Use this method only when the work in the live log has no value. Microsoft states that REPLACE deletes the existing database and overrides the requirement to take a tail log backup. Use it on a test copy or on a database with lost log files.
RESTORE DATABASE [OrdersDB]
FROM DISK = N'D:\Backup\OrdersDB_full.bak'
WITH REPLACE, RECOVERY;
Heads UpCopy the MDF and LDF files of the live database to another disk before you use REPLACE. REPLACE cannot be undone and you cannot recover the dropped log work afterward.
Questions People Ask About Error 3159
Can You Ignore Error 3159?
No. SQL Server stops the restore to protect the work in the log. Take the tail log backup or choose STOPAT or REPLACE on purpose.
Does Error 3159 Appear in the SIMPLE Recovery Model?
No. Microsoft ties the tail log requirement to the full and bulk logged recovery models. The SIMPLE model keeps no log backups.
What Does NORECOVERY Do in BACKUP LOG?
NORECOVERY leaves the database in the restoring state after the backup. No transaction can change the database before your restore starts.
Is a Tail Log Backup With Incomplete Metadata Usable?
Yes. Microsoft states that the captured log is complete and only the metadata is incomplete. The HasIncompleteMetadata column shows 1 in RESTORE HEADERONLY output.
What Happens When the Tail Log Backup Fails?
Every transaction committed after your latest log backup is lost. Restore to a point in time with STOPAT or overwrite the database with REPLACE.
How to Stop Error 3159 Before the Next Restore?
Write the tail log backup into every restore script so it executes before the first RESTORE statement. Schedule log backups at short intervals so the tail stays short.
Test the full restore sequence on a copy of the database every month. A tested script removes the guesswork when a real failure arrives.
Who, How and WhyAndrew Jackson, Technical Content Specialist, wrote this guide. The error text, the explanation and the user actions follow the Microsoft Learn pages for error 3159, tail log backups and the RESTORE arguments linked above. The T-SQL was checked for syntax against Microsoft documentation and was not executed on a live server. The guide exists because restore errors need a clear way to match the message to the state of the database.
Key Takeaways
- SQL Server error 3159 means a restore would overwrite log records that no backup holds.
- BACKUP LOG WITH NORECOVERY saves the tail of an online database.
- NO_TRUNCATE fits an offline database and CONTINUE_AFTER_ERROR fits a damaged one.
- STOPAT on RESTORE LOG sets the recovery point inside the log backups you already hold.
- REPLACE deletes the existing database and drops the work in the log.