从.bak文件中恢复数据

时间:2019-12-21 16:02:13

标签: sql-server restore

请使用有关如何恢复非标准SQL Server .bak备份文件的提示。

背景:我们有一个有效的发票计划,其中包含来自已废止提供商的10多年的数据。在过去的通信中,提供程序告诉我们该产品基于SQL Server构建,但从未告诉我们什么版本。

我们的目标是从程序中导出数据,将其重新格式化,然后将其加载到另一个会计系统中。该程序本身没有完整的导出工具,因此我们希望从其创建的.bak文件中访问数据,以获取所有数据以导入到新系统中。

我尝试了以下SQL Server版本,但未成功:

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

我还尝试过使用...进行恢复

  • Microsoft SQL Server Management Studio 18,但未列出要还原的备份集
  • SysTools SQL备份恢复,但返回“无法识别所选.bak文件的SQL Server版本。”
  • Linux计算机上的SQL Server 2017,并获得以下输出...
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

带有虚拟数据is available here.bak文件。


更新#1 -回复@DavidJamesSmith

这就是我得到的...

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.

更新#2 -再次回复@DavidJamesSmith

据我所知,该文件是 加密的。我可以使用gHex(GNOME中的十六进制编辑器)打开文件,然后读取数据。

关于文件损坏的问题,我认为不是。无论.bak文件是在创建.bak的计算机上还是在我将文件传输到的另一台计算机上,在此程序创建的任何.bak文件上都遇到相同的错误。 / p>

如果文件已损坏,则说明程序本身正在导出损坏的版本。

这是我在具有帐户软件本身的计算机上运行的新导出中得到的内容。

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.

1 个答案:

答案 0 :(得分:0)

帐户软件使用的是Microsoft SQL Server Compact 3.5 Service Pack 2。

感谢大家的帮助,尤其是@lptr,这是使我进入正确轨道的提示。

相关问题