Search code examples
sql-serverrestore

Recover Data from .bak File


I could use tips on how to recover a non-standard SQL Server .bak backup file, please.

The background: we have a functioning invoicing program with over 10 years of data from a defunct provider. In past correspondence, the provider told us that the product was built on SQL Server, but never told us what version.

Our goal is to export the data from the program, reformat it, and then load it into another accounting system. The program itself does not have a complete set of export tools so we are hoping to access the data from the .bak files it creates to get all the data for importing into the new system.

I have tried the following SQL Server versions without success:

  • 2000
  • 2005
  • 2008
  • 2008 R2
  • 2012
  • 2014
  • 2016
  • 2017

I have also tried recovering with...

  • Microsoft SQL Server Management Studio 18 but no backup sets are listed for restoration
  • SysTools SQL Backup recovery but it returns "Could not identify SQL Server version for the selected .bak file."
  • SQL Server 2017 on a Linux machine and get the following output...
1> restore database newhouse from disk='/home/me/test.bak'
2> go
Msg 3241, Level 16, State 1, Server 8350, Line 1
The media family on device '/home/me/test.bak' is incorrectly formed. SQL Server cannot process this media family.
Msg 3013, Level 16, State 1, Server 8350, Line 1
RESTORE DATABASE is terminating abnormally.
1> restore verifyonly from disk='/home/me/test.bak'
2> go
Msg 3241, Level 16, State 1, Server 8350, Line 1
The media family on device '/home/me/test.bak' is incorrectly formed. SQL Server cannot process this media family.
Msg 3013, Level 16, State 1, Server 8350, Line 1
VERIFY DATABASE is terminating abnormally.
1> restore headeronly from disk='/home/me/test.bak' with nounload
2> go
Msg 3241, Level 16, State 1, Server 8350, Line 1
The media family on device '/home/me/test.bak' is incorrectly formed. SQL Server cannot process this media family.
Msg 3013, Level 16, State 1, Server 8350, Line 1
RESTORE HEADERONLY is terminating abnormally.
1> restore headeronly from disk='/home/me/test.bak' 
2> go
Msg 3241, Level 16, State 1, Server 8350, Line 1
The media family on device '/home/me/test.bak' is incorrectly formed. SQL Server cannot process this media family.
Msg 3013, Level 16, State 1, Server 8350, Line 1

A .bak file with fictitious data is available here.


Update #1 - in reply @DavidJamesSmith

Here is what I get...

1> restore headeronly 
2> from disk = N'/home/me/test.bak' 
3> go 
Msg 3241, Level 16, State 1, Server 8350, Line 1 
The media family on device '/home/me/test.bak' is incorrectly formed. SQL Server cannot process this media family. 
Msg 3013, Level 16, State 1, Server 8350, Line 1 
RESTORE HEADERONLY is terminating abnormally.

Update #2 - again in reply @DavidJamesSmith

From what I can tell, the file is not encrypted. I can open the file with gHex - a hex editor in GNOME - and read the data.

As far as the question about the file being corrupted, I do not believe so. I get the same error on any .bak file created by this program whether the .bak file is on the machine that create the .bak or on another machine that I have transferred the file to.

If the file is corrupted, than the program itself is exporting a corrupted version.

Here is what I get on a fresh export running on the machine that has the account software itself.

1> use newhouse
2> restore database newhouserecovery from
3> disk = N'C:\Program Files\Microsoft SQL Server\MSSQL14.SQLEXPRESS\MSSQL\Backup\test.bak'
4> with
5> file = 1,
6> move N'test' to N'C:\Users\me\Backup\test.mdf',
7> move N'test_log' to N'C:\Users\me\Backup\test_log.ldf',
8> nounload,
9> stats = 5
10> go
Changed database context to 'newhouse'.
Msg 3241, Level 16, State 1, Server DESKTO\SQLEXPRESS, Line 2
The media family on device 'C:\Program Files\Microsoft SQL Server\MSSQL14.SQLEXPRESS\MSSQL\Backup\test.bak' is incorrectly formed. SQL Server cannot process this media family.
Msg 3013, Level 16, State 1, Server DESKTO\SQLEXPRESS, Line 2
RESTORE DATABASE is terminating abnormally.

Solution

  • The account software was using Microsoft SQL Server Compact 3.5 Service Pack 2.

    Thanks for everyone's help and, especially @lptr for the tip that got me going down the correct track.