Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question

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.

share|improve this answer
4  
"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

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...

share|improve this answer
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

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?

share|improve this answer

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
share|improve this answer
    
The point about versions has been repeated in other answers. – Andriy M May 21 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 at 10:45

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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