How to read the meta data out of SQL Server backup

2019-06-17 09:55发布

Generally to get the meta data from SQL Server backup files, we need to use TSQL commands like restore headeronly or restore filelistonly. However, there are some third party tools can read this information directly from the backup files, like this one http://www.yohz.com/sqlbakreader_details.htm. Since this tool don't have a command line version, which makes it less useful. I want to know whether there are some ways that I can read this data directly.

Thanks.

2条回答
该账号已被封号
2楼-- · 2019-06-17 10:39

I think you may be able to use SQL Servers SMO libraries and write your own in .net or Powershell. If you take a look at this page http://msdn.microsoft.com/en-us/library/microsoft.sqlserver.management.smo.restore.readbackupheader.aspx there are code samples in VB.Net and Powershell.

查看更多
迷人小祖宗
3楼-- · 2019-06-17 10:47

The .bak file is a Microsoft Tape Format file. Here's a PDF that contains the format.

Of interest to you will be:

enter image description here

For a quick dump (if you are on the SQL Server in question that created the backup), you can do select from the [msdb].[dbo].[backup*] tables.

See this article for more info.

查看更多
登录 后发表回答