How to read metadata from SQL Server backup files directly?

Typically, to retrieve metadata from SQL Server backup files, we need to use TSQL commands, such as restore headeronly or restore filelistonly . However, some third-party tools can read this information directly from backup files, for example, http://www.yohz.com/sqlbakreader_details.htm . Since this tool does not have a command line version, which makes it less useful. I want to know if there are some ways I can directly read this data.

Thanks.

+6
source share
2 answers

The .bak file is a Microsoft tape format file. Here is a PDF that contains the format.

You will be interesting to you:

enter image description here

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

See the article for more details.

+8
source

I think you can use SMO libraries for SQL Servers and write your own in .net or Powershell. If you 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.

0
source

Source: https://habr.com/ru/post/950007/


All Articles