SQL Server Log Explorer
SQL Backup & Restore Error 3117

SQL Server Error 3117 and 4 Ways to Fix It

Andrew Jackson Published: 9 Minutes Reading
On this page

Quick Answer

Fix SQL Server error 3117 in 4 ways. Error 3117 means your database is online and refuses more backups. Start with the full file and use WITH NORECOVERY in SSMS or T-SQL. Use STANDBY when you need query access between restores. Find a matching full backup in msdb when the chain is broken. Test every restore on a copy first.

SQL Server error 3117 appears when you restore a differential or log backup onto a database that is not waiting for more backups. SQL Server says no files are ready to roll forward and stops the restore.

This guide explains the message, shows how to check your database state and gives 4 methods that finish the restore without losing the chain.

What is SQL Server Error 3117?

SQL Server error 3117 is a restore error. It stops RESTORE DATABASE or RESTORE LOG when the destination database is already recovered or does not exist yet.

Msg 3117, Level 16, State 4, Line 1
The log or differential backup cannot be restored because no files are ready to rollforward.
Msg 3013, Level 16, State 1, Line 1
RESTORE DATABASE is terminating abnormally.
Message part Meaning
Msg 3117 The destination database is not in the RESTORING state
no files are ready to rollforward SQL Server has no restored data file that waits for later backups
Msg 3013 The restore ended and applied nothing from this backup

According to Microsoft, you restore the full or differential backup first and then every log backup in chronological order. After recovery completes, the database goes online and takes no more log backups.

What Causes SQL Server Error 3117?

Five causes produce error 3117. This table links every cause to a method.

Cause What happened Fix
Full backup restored WITH RECOVERY The database went online and closed the chain Method #1 or #2
No full backup restored first The destination database does not exist or contains other data Method #1 or #2
SSMS option left on default The restore dialog used its default recovery option Method #1
Query access needed between restores Someone recovered the database to query it Method #3
Lost or wrong full backup No full backup matches the differential or the log Method #4

How do You Check the Database State Before a Restore?

Check the state first so you know which method fits.

SELECT name, state_desc, recovery_model_desc
FROM sys.databases
WHERE name = N'YourDatabase';
state_desc Meaning Next step
RESTORING The database waits for more backups Restore the differential or log WITH NORECOVERY
ONLINE The database is recovered and open Method #1 or #2
No row returned The database does not exist Restore the full backup first

What are the System and Software Specifications?

These tables list what the destination server needs before you restore. Hardware figures come from the Microsoft SQL Server 2022 requirements page.

System Specifications

Component Requirement
Processor x64 processor with 1.4 GHz minimum and 2.0 GHz or faster recommended
Memory 1 GB minimum (512 MB for Express) and 4 GB or more recommended
Storage 6 GB for SQL Server setup plus free space equal to the size of the database you restore
Backup files The SQL Server service account needs permission to open the folder that contains every file

Software Specifications

Item Requirement
SQL Server version Same version as the source server or a newer one. You cannot restore to an older version
Permissions sysadmin or dbcreator server role for a database that does not exist yet
Backup set One full backup and every differential or log backup of the same chain
Client tool SQL Server Management Studio or sqlcmd

Which 4 Methods Fix SQL Server Error 3117?

Method Best for Main limit
Restore in SSMS with NORECOVERY You prefer a dialog and one database Restarts the restore from the full backup
Restore with T-SQL You restore many files or script the task You type every file path
Restore WITH STANDBY You need to query data between log restores Database opens for queries only until the last log
Match the full backup by LSN The full file is lost or does not match Needs backup history or file headers

Method #1: Restore in SSMS With NORECOVERY (Free, Start Here)

SSMS recovers the database after the full backup unless you edit one option. This method makes the database wait in the restoring state.

  • Right click Databases and select Restore Database.
  • Select Device and add your full backup file. Add the differential or log files in the same list.
  • Open the Options page.
  • Select Leave the database non-operational, and do not roll back uncommitted transactions for the full backup step.
  • Tick Overwrite the existing database (WITH REPLACE) when the database is online and contains data you can lose.
  • Select OK and restore the differential and log backups one after another.
  • Select Leave the database ready to use only for the last backup.

Heads Up. WITH REPLACE overwrites the live database. Confirm that you restore to the right server and save a copy of the current files.

See our SQL Server NORECOVERY option guide for the full list of restore options.

Method #2: Restore With T-SQL (Free, Scriptable)

T-SQL shows every step and lists the files in restore order. Replace the names and the paths with yours.

RESTORE DATABASE [YourDatabase]
FROM DISK = N'D:\Backups\YourDatabase_full.bak'
WITH NORECOVERY, REPLACE;

RESTORE DATABASE [YourDatabase]
FROM DISK = N'D:\Backups\YourDatabase_diff.bak'
WITH NORECOVERY;

RESTORE LOG [YourDatabase]
FROM DISK = N'D:\Backups\YourDatabase_log_1.trn'
WITH NORECOVERY;

RESTORE LOG [YourDatabase]
FROM DISK = N'D:\Backups\YourDatabase_log_2.trn'
WITH NORECOVERY;

RESTORE DATABASE [YourDatabase] WITH RECOVERY;

Microsoft recommends that you restore every log backup WITH NORECOVERY and recover the database in a separate last step. Your last statement above does exactly that.

Heads Up. Samples on this page follow the Microsoft syntax with placeholder names. Execute them on a test server first.

Use our create a differential backup in SQL Server guide if you need a new differential file.

Method #3: Restore WITH STANDBY for Query Access Between Restores (Free, Queries Only)

People recover a database to query it and then meet error 3117 on the next log. STANDBY solves that because the database opens for queries only and still accepts later backups.

RESTORE DATABASE [YourDatabase]
FROM DISK = N'D:\Backups\YourDatabase_full.bak'
WITH STANDBY = N'D:\Backups\YourDatabase_undo.bak';

RESTORE LOG [YourDatabase]
FROM DISK = N'D:\Backups\YourDatabase_log_1.trn'
WITH STANDBY = N'D:\Backups\YourDatabase_undo.bak';
  • Query access. Query the database after every log restore.
  • Undo file. SQL Server writes the uncommitted work into the standby file and reapplies it at the next restore.
  • Final step. Restore the last log WITH RECOVERY to open the database for writes.

Log shipping secondary servers use the same option. See our SQL Server transaction log shipping guide for that setup.

Method #4: Find the Matching Full Backup (Free, Needs Backup History)

Error 3117 also appears when you restore a log backup onto a database that came from a different full backup. List the backups of the source database and select the chain that belongs together.

SELECT bs.type, bs.backup_start_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 bs.media_set_id = bmf.media_set_id
WHERE bs.database_name = N'YourDatabase'
ORDER BY bs.backup_start_date;

According to Microsoft, DatabaseBackupLSN is the log sequence number of the most recent full database backup. Full backups and the differential and log files built on them share the same value. On a new server without msdb history, check the file headers instead.

RESTORE HEADERONLY FROM DISK = N'D:\Backups\YourDatabase_full.bak';
RESTORE HEADERONLY FROM DISK = N'D:\Backups\YourDatabase_diff.bak';

Compare DatabaseBackupLSN in both headers. Equal values mean the files belong together.

DifferentialBaseLSN in a differential backup also equals the FirstLSN of its full backup. Restore that full file and then follow Method #2. Take a new full backup on the source when no matching file remains.

Our SQL Server error 4305 guide covers a gap inside the log chain.

Which Errors Look Like SQL Server Error 3117?

Error Cause Fix
3136, wrong earlier state The differential belongs to another full backup Restore the matching full backup
4305, too recent to apply A log backup is missing in the chain Restore the missing log backup first
3159, tail of the log not backed up You restore over a live database with unsaved log records Take a tail log backup first
3241, media family incorrectly formed The backup file is damaged or from another format Execute RESTORE VERIFYONLY and use a good copy

Our SQL Server error 3159 and SQL Server error 3241 guides explain two of these rows.

How do You Prevent SQL Server Error 3117?

Four habits protect the restore chain.

  • Record the order. List the full, differential and log files in the order you restore them.
  • Use NORECOVERY on every step. Reserve RECOVERY for the last statement only.
  • Test on a copy. Restore to a test server before you touch production.
  • Verify the files. Execute RESTORE VERIFYONLY on every backup after it is written.

Plan the schedule with our backup and restore strategy in SQL Server guide.

FAQs

What does SQL Server Error 3117 Mean?

Your destination database is not waiting for more backups. SQL Server recovered it or never restored a full backup into it.

Can You Restore a Differential Backup After WITH RECOVERY?

No. Microsoft states that no more backups apply after recovery completes. Restore the full file again WITH NORECOVERY.

Does Error 3117 Mean the Backup File is Corrupt?

No. Your file is healthy and SQL Server refuses it because of the database state. Confirm the file with RESTORE VERIFYONLY.

How do You Restore a Differential Backup in SQL Server?

Restore the matching full backup WITH NORECOVERY. Restore the newest differential WITH NORECOVERY or WITH RECOVERY when it is the last file.

Why does Error 3117 Appear in Log Shipping?

Someone recovered the secondary database. Restore the secondary again from a full backup and reapply the log files.

Can You Query Data While Log Backups Wait to Restore?

Yes. Use WITH STANDBY and the database opens for queries only after every restore.

Does WITH REPLACE Delete My Current Database?

Yes. WITH REPLACE overwrites the existing database with the backup. Take a copy of the live files before you use it.

Final Verdict

Error 3117 always points to the database state and never to the backup file. Restore the full backup WITH NORECOVERY and apply every later file in order.

Use STANDBY when you need query access on the way. Microsoft documents the restore sequence on its apply transaction log backups page and the options on its RESTORE statements page.