31

I am trying to restore a .BAK in SQL server but get the following error:

Msg 3241, Level 16, State 7, Line 1 The media family on device 'c:\glyn\JA.bak' is incorrectly formed. SQL Server cannot process this media family. Msg 3013, Level 16, State 1, Line 1 RESTORE DATABASE is terminating abnormally.

I have tried restoring using 2012, 2008 and even 2005 but nothing works, I have used the following query and through the Tasks >> Back up but nothing works, here's my SQL:

RESTORE DATABASE JA FROM DISK='c:\glyn\JA.bak'

Does anyone have any suggestions? I've read that the bak could be corrupt, it was sent to my by another developer on DVD who is working on the project.

12

If you are attempting to restore newer database to older SQL version you can always simply manually create the database in the older SQL version and utilize the task - generate scripts and include the data.

Save to File --> Advanced--> Types of data to script --> Schema and data.

Also make sure to Script for Server Version.

This might be the only supported option if you're trying to go from newer SQL Server to older version.

Related: Restore SQL Server 2012 backup to a SQL Server 2008 database?

  • Seems like a hack but I guess this worked around this issue in my case. – jpierson Oct 31 '16 at 19:12
7

I found this that says that your backup file is corrupted. Possibly transfered by FTP in text mode rather than binary.

And this blog that lists how someone else fixed the same problem.

  • 8
    "lists how someone else fixed the same problem" generally on SE network sites you should post the relevant bits of things like blog posts; it prevents link decay – jcollum Dec 31 '14 at 20:57
6

I had the same problem, my script was specifying the incorrect FILE type, I had a .bak and I was specifying FILE = 2 which is a .trn.

USE [master]
RESTORE DATABASE [MyNewDB] FROM
DISK = N'D:\MyOldDB.bak'
WITH
    FILE = 1, -- 1 = .bak, 2 = .trn type backup
    MOVE N'MyOldDB' TO N'd:\data\MyOldDB.mdf',
    MOVE N'MyOldDB_log' TO N'd:\data\MyOldDB_log.ldf',
    NOUNLOAD,
    STATS = 5    
GO

I'm not sure if the RESTORE command auto-detects or sets a default for this...

  • 1
    The error turns around this, the problem is when you use the GUI to restore databases, SQL Managment Studio does not provide you detailed information. If you try to restore using t-sql script, sql server will report you to use MOVE option. – dlopezgonzalez Dec 1 '15 at 9:37
5

Run the following script on source and destination SQL Servers, the versions should either match or the destination should have a higher version of SQL Server otherwise you cannot restore the .bak file:

SELECT @@Version
  • The point about versions has been repeated in other answers. – Andriy M May 21 '16 at 23:01
  • 1
    @AndriyM you are right, but a practical action was missing. We are not talking about history or geography, some command or code should be mentioned. – Shadi Namrouti May 22 '16 at 10:45
1

The only reason is you are trying to restore lower version backup, Refer: http://www.sqlservercentral.com/Forums/Topic1675066-1550-1.aspx?Update=1

-4

delete corrupted file and re-run the backup

  • 4
    Hi, Welcome to the site. We like a bit more detail on how why or how this would work. – Tom V Oct 27 '16 at 20:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.