The tail of the log for the database “database_name” has not been backed up



Msg 3159, Level 16, State 1, Line 2
The tail of the log for the database “TestDB” has not been backed up. Use BACKUP LOG WITH NORECOVERY to backup the log if it contains work 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 2
RESTORE DATABASE is terminating abnormally.


You receive this error message when you try to restore a database.

The reason for the error is that the backup file that you are trying to restore is older than the database you are trying to restore.

For example, you took a backup of your database named “TestDB” on December 22, 2007. After that there were some changes on the database. On the 23rd of the month, you wanted to restore the backup you received on the 22nd of the month over the “TestDB” database for some reason. That’s when you get this error.


In fact, this is some kind of protection system. The intention is to prevent your old data from being overwritten by your new data and this feature came with SQL Server 2005.

You can use two methods to overcome this protection system (which actually tells the solution within the warning message).

Method 1: You can restore your database to the current database by using the most up-to-date Log backup of your database (using the NO_TRUNCATE and NORECOVERY parameters).

Method 2: In this method, you can restore your old backup to your current database using the REPLACE parameter together with the RESTORE command (with no backups). What you should consider about this method is that all changes made to your database will be lost after the date you took this restored backup.

Note: In later versions of SQL Server, if you want to do this through SSMS, you will see an alert as follows.

A tail-log backup of the source database will be taken. View this setting on the Options page.


When we switch to Options tab we will see a screen as below. As you can see, it is designed to automatically take the tail log backup for protection purposes before Restore. If you uncheck the “Take tail-log backup before restore”, you get the error that is subject to the article.

Ekrem Önsoy
Author: Ekrem Önsoy

The original article was written in Turkish by Ekrem Önsoy and translated to English by dbtut with the consent of the author. The copyright of the article belongs to the author. The author shall not be liable in any way for any defect caused by translation.

Leave a Reply

Your email address will not be published. Required fields are marked *