RESTORE Is Terminating Abnormally (Errors 3013 and 3241)

🚨Part of the SQL Server Errors series, the exact messages and what actually causes them.

If RESTORE ends with Msg 3013, find the SQL Server message immediately before it. That is the one to investigate.

⚡Msg 3013 is the closing line, not the cause. Read the message immediately before it. If that message is 3241, check the backup file before retrying the restore.

What Msg 3013 Says

Msg 3013  ·  Level 16  ·  State 1
RESTORE DATABASE is terminating abnormally.

Msg 3013 means the RESTORE operation stopped; it does not name the cause. Microsoft Docs describes it as a generic error that appears with more specific messages.

SSMS Messages tab after RESTORE DATABASE from a file that is not a backup: Msg 3241, Level 16, State 0, the media family is incorrectly formed, then Msg 3013, RESTORE DATABASE is terminating abnormally

The five failures below show why the preceding message matters: the same 3013 line followed different errors, while the backup restored once the target and connection were correct.

How this was tested SQL Server 2025 (17.0) on the lab instance. A small lab database, a good full backup of it, then five deliberate ways of failing to restore, plus the same backup restoring cleanly to prove the file was good all along. The captures come from two runs on that instance, so the names differ: Lab1031 for the 3241 capture at the top, and Lab1117_rst with its backup Lab1117_rst.bak for the rest, where Lab1117_other is the different existing database. Every message in the screenshots is what that instance returned.

Find the Cause Before 3013

What was wrongThe real errorWhat it tells you
The file is not a backup at all3241Wrong file, a download that failed, or a backup written by something else. The file is unreadable as a backup.
The backup file is truncated3287The copy did not finish. Different error to 3241, and it names the file ID it could not read.
The target path is not usable5133, then 3156Nothing wrong with the backup. Operating system error 5 means the service account cannot write to the folder; error 2 means the folder does not exist.
The database is in use3102Nothing wrong with anything. You are connected to the database you are restoring over.
Backup is of a different database3154Right file, wrong target, or a target that already exists under that name.

Only two of those five are a problem with the backup file. The other three are a problem with where you are restoring it to, or what you are connected to, and those are free to fix. Treating every 3013 as “the backup is corrupt” sends you looking for a new backup when the one you have is fine.

Unreadable media3241, the file is not a backup

This is the pairing people mean when they say “3013”, and it is the screenshot at the top of this page. In practice it is the wrong file, a download that failed, or a backup taken by a third-party tool that writes its own format. A backup from a newer version of SQL Server is not this case: that restore stops with 3169, which names both versions, so it never looks like corruption.

Truncated backup3287, the file is a backup but not all of it
SSMS Messages tab after RESTORE DATABASE Lab1117_trunc from a truncated backup copy: Msg 3287, the file ID 1 on the device is incorrectly formed and can not be read, then Msg 3013, RESTORE DATABASE is terminating abnormally

A genuinely different error from 3241, produced here by cutting a good backup short. SQL Server recognised the header and then ran out of file. If you see 3287, compare the file size against the source before concluding anything about corruption. This is usually a copy that was interrupted.

Invalid target path5133 and 3156, and SQL Server telling you outright to read up
SSMS Messages tab after a restore WITH MOVE to a folder the SQL Server service cannot write to: Msg 5133 with operating system error 5, Access is denied, and Msg 3156 for the data and log file, then Msg 3119 and Msg 3013

Read the line above 3013. Msg 3119, “Previous messages provide details”, is SQL Server saying, in its own words, that 3013 is not the answer and the answer is further up. Above it sit a 5133 and a 3156 for each file, data and log. The 5133 carries operating system error 5, Access is denied: the SQL Server service account cannot write to that folder. The backup here was perfectly good. A folder that does not exist fails the same way, with operating system error 2 in the 5133 instead.

Database in use3102, you are standing in it
SSMS Messages tab after RESTORE DATABASE Lab1117_rst from a session connected to Lab1117_rst: Msg 3102, the database is in use by this session, then Msg 3013

The most embarrassing and probably the most common. Your query window is connected to the database you are restoring over. The fix is in the message: connect to master first. Other sessions holding the database produce a similar refusal, which is what SINGLE_USER WITH ROLLBACK IMMEDIATE is for.

Different target database3154, right backup, wrong target
SSMS Messages tab after restoring the Lab1117_rst backup over Lab1117_other: Msg 3154, the backup set holds a backup of a database other than the existing database, then Msg 3013

Restoring one database’s backup over a different existing database. This one has a page of its own, because the safe fix and the dangerous fix look very similar.


Check Whether the Backup File Is Readable

Before restoring anything, three read-only statements tell you whether the file is the problem. Neither writes anything and neither needs the target database.

-- What is actually in this file? Database name, size, LSNs, version it came from.
RESTORE HEADERONLY FROM DISK = 'D:\Backups\sales.bak';

-- The logical file names, which is what WITH MOVE needs.
RESTORE FILELISTONLY FROM DISK = 'D:\Backups\sales.bak';

-- Read the whole backup and check it, without restoring it.
RESTORE VERIFYONLY FROM DISK = 'D:\Backups\sales.bak';

This splits the diagnosis in one step. Run HEADERONLY against the file that failed:

  • It fails too, and the problem is the file. On the lab instance, HEADERONLY against a one-line text file saved as sales.bak returned Msg 3254, the volume on the device is empty, followed by RESTORE HEADERONLY is terminating abnormally. Two files that were not backups gave two different messages, 3241 at the top of this page and 3254 here, so read the message rather than expecting one number.
  • It succeeds, and the file is fine. Your problem is the target, the paths, or the session, which is three of the five cases above.
SSMS Messages tab after RESTORE HEADERONLY against a text file named sales.bak: Msg 3254, the volume on the device is empty, then Msg 3013, RESTORE HEADERONLY is terminating abnormally

One exception: an encrypted backup. A backup taken WITH ENCRYPTION and read on a server that does not hold its certificate fails HEADERONLY as well, with Msg 33111 “Cannot find server certificate with thumbprint” above the 3013, and nothing is wrong with the file. A TDE database’s backup restored without its certificate stops on the same 33111. Cannot Find Server Certificate (Error 33111) covers putting the certificate back.

Note that 3013’s text follows the statement you ran. It says RESTORE HEADERONLY is terminating abnormally there rather than RESTORE DATABASE, which is a small confirmation that it is a closing line rather than a diagnosis.

And to close the loop: the same backup behind the path, in-use and different-database failures restored cleanly the moment it was pointed at a valid folder from a session on master.

SSMS Messages tab after the same backup restored from master to the DATA folder as Lab1117_rst_copy: 440 pages for the data file, 2 for the log, then RESTORE DATABASE successfully processed 442 pages

Get the Full Message Text

If all you have is 3013, the useful line was thrown away before it reached you. Where to find it:

  • SQL Agent job history truncates. Open the step’s output file if it has one, or set one, rather than reading the summary.
  • The SQL Server error log has the real error even when the client only showed the last line. Restore failures are written there with their causes.
  • Applications and ORMs often surface only the final message. Rerun the restore by hand in SSMS or sqlcmd and read the whole output.
  • In PowerShell, capture the verbose stream, because Invoke-Sqlcmd puts informational and error detail there rather than in the return value.

Avoid These Restore Mistakes

  • Do not conclude the backup is corrupt from a 3013. Three of the five reproduced causes had nothing wrong with the backup file at all.
  • Do not go looking for an older backup first. Run RESTORE VERIFYONLY on the one you have. It takes seconds and answers the question.
  • Do not add WITH REPLACE to make an error go away. It suppresses the safety check behind 3154, and its whole job is to stop you overwriting the wrong database.
  • Do not retry the identical statement. Every case here failed the same way every time. Read the line above the 3013 instead.
  • Do not restore from the database you are replacing. Connect to master. That is the database-in-use case.

Frequently Asked Questions

How do I fix error 3013?
You do not, directly. 3013 reports that the restore stopped, and it is the same message whatever went wrong. Find the error printed immediately before it: across five reproduced failures that was 3241, 3287, 5133 with 3156, 3102 or 3154, each with a completely different fix.
My tool only shows 3013. Now what?
Rerun the restore by hand in SSMS or sqlcmd and read the whole output, or open the SQL Server error log, which records the real error even when the client showed only the closing line. Agent job history in particular truncates the useful part.
Does 3241 always mean the backup is corrupt?
Not necessarily. It means SQL Server cannot read the file as a backup, which also covers the wrong file entirely, a download that failed and a third-party format. A backup from a newer version of SQL Server is a different message, 3169, which names both versions.
What is the difference between 3241 and 3287?
3241 is “this is not a backup media family I can process”. 3287 is “this is a backup, and the file ID inside it cannot be read”, which in testing came from a backup that had been truncated. 3287 points more strongly at an interrupted copy, so compare the file size against the source first.
Can I check a backup without restoring it?
Yes, and you should. RESTORE VERIFYONLY reads and checks the whole backup, RESTORE HEADERONLY tells you what is in it, and RESTORE FILELISTONLY gives the logical file names for WITH MOVE. All three are read-only and none need the target database to exist.
Why did several errors appear before 3013?
Because a restore validates every file. In the reproduced bad-path case, each of the data file and the log file produced a 5133 and a 3156, then Msg 3119 reading “Problems were identified while planning for the RESTORE statement. Previous messages provide details”, then 3013. SQL Server is explicitly pointing you upwards.


Where To Go Next

Start with the message before 3013, then follow the specific restore failure or check you need.

Comments

Leave a Reply

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