Recover Data from .bak File - sql-server

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.

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.

Related

T-SQL Backup/Restore to/from URL does not work on SQL Server 2017 Web Edition on Ubuntu Linux 16.04 LTS

I tried, without success, to run a T-SQL script to Backup to URL and another one to Restore to URL on SQL Server 2017 Web Edition, which is running on Ubuntu 16.04 LTS. The credential was successfully created.
Here's an example of the T-SQL for Backup that I'm trying to run:
DECLARE #name varchar(100)
DECLARE #fileURL varchar(100)
SET #name = 'test-db'
SET #fileURL = 'https://mystorageaccountname.blob.core.windows.net/databases/test-db.BAK'
BACKUP DATABASE #name
TO URL = #fileURL
WITH CREDENTIAL = 'mycredential'
,COMPRESSION
,STATS = 5;
Here's the error that I'm getting on MSSQL Management Studio:
Msg 3292, Level 16, State 6, Line 5
A failure occurred while attempting to execute Backup or Restore with a URL device specified. Consult the operating system error log for details.
Msg 3013, Level 16, State 1, Line 5
BACKUP DATABASE is terminating abnormally.
Here's the error that I'm getting on /var/log/syslog:
#015VDI: "C:\binn\BackupToUrl.exe" "b" "p" "680074007400700073003A002F002F0073007700650065007400640061007400610062006100730065006200610063006B007500700073002E0062006C006F0062002E0063006F00720065002E00770069006E0064006F00770073002E006E00650074002F006400610074006100620061007300650073002F0068006300640061006D006F00620069006C0065002E00420041004B00" "73007700650065007400640061007400610062006100730065006200610063006B00750070007300" "01000000D08C9DDF0115D1118C7A00C04FC297EB010000008AB2169DF1DE3A45B5514DCCD09182C3000000001200000061007A007500720065006B006500790000001066000000010000200000008ECF1319A21E667E0E32E83135C57DFCAF4E3DFF2AABDA00E3E2D814B5C88D2E000000000E8000000002000020000000E9E64579DF38EA0E66886B8D454C4F4256A682A124E70D86EC0DA087112ECA0450000000F92ED8FD343DADDE9518C412CA5EAB188316B24A6A0B407CCEA9AE142A9DBC282085ABF133BFDF017A3AFA9CEB4C5039433D15FA47A64A1339F2D030ED3383C58F81A2C3634FA945B6B819F113AB22DF40000000E9CDF76A290F18299BBE99C273FCA31E4622334C645EBFE8C5AA9C4F68C1A323A2F0EED33B8F6E8D5922B5B78DE1F6DB456864A290689C98A3631EA3F62505D3" "NOFORMAT" "4D005300530051004C00530045005200560045005200" "" "DB" "68006300640061006D006F00620069006C006500" "NOTRACE"
#015BackupToUrl: couldn't load process Error Code: 80070002
#0152018-03-14 12:35:25.30 Backup Error: 3041, Severity: 16, State: 1.
#0152018-03-14 12:35:25.30 Backup BACKUP failed to complete the command BACKUP DATABASE hcdamobile. Check the backup application log for detailed messages.
Have you guys had this problem before? Do I need to install any additional package to be able to run Backup to URL on Linux?

I am trying to backup a database and am getting MSG 3013

I have tried to backup in Microsoft SSMS with the GUI backup task, and it fails after a few seconds, so then I tried running this command:
BACKUP DATABASE databasename TO DISK = 'd:\databasename_full.Bak' WITH FORMAT, MEDIANAME = 'd_datbasenamebackup', NAME = 'Full Backup of databasename';
And get a very generic error of the following
Msg 3013, Level 16, State 1, Line 1 BACKUP DATABASE is terminating abnormally.
I am wondering if anyone has come across this error before. Everything I have read is saying there is a media fault, which I know isn't the case.
There is a Microsoft support page for this Error Message 3013.
It is apparently caused when a filemark in your backup device could not be read. Resolution steps below:
To allow SQL Server to perform new backups to the backup device, you
must manually delete or erase the device by using the following
command:
BACKUP DATABASE mydatabase TO DISK='C:\MyDatabase.bak' with FORMAT

Error while restoring db from Enterprise to BI edition of SQL Server

Every day we restore backups from production on 3 different servers. Same process has been used for months and it always works. Recently we decided to start restoring backups from production server on the 4th server meant for BI. We are however unable to do it as database restores well at first and once the restore finishes database goes into "Suspect" mode and the following message is displayed:
Msg 3908, Level 16, State 1, Line 3
Could not run BEGIN TRANSACTION in database 'DatabaseName' because the database is in emergency mode or is damaged and must be restarted.
Msg 3314, Level 16, State 3, Line 3
During undoing of a logged operation in database 'DatabaseName', an error occurred at log record ID (205933:123232:2). Typically, the specific failure is logged previously as an error in the Windows Event Log service. Restore the database or file from a backup, or repair the database.
Msg 3013, Level 16, State 1, Line 3
RESTORE DATABASE is terminating abnormally.
Msg 934, Level 21, State 1, Line 3
SQL Server cannot load database 'DatabaseName' because Change Data Capture is enabled. The currently installed edition of SQL Server does not support Change Data Capture. Either disable Change Data Capture in the database by using a supported edition of SQL Server, or upgrade the instance to one that supports Change Data Capture.
Msg 933, Level 21, State 1, Line 3
Database 'DatabaseName' cannot be started because some of the database functionality is not available in the current edition of SQL Server.
Msg 3314, Level 21, State 5, Line 3
During undoing of a logged operation in database 'DatabaseName', an error occurred at log record ID (205933:123232:1). Typically, the specific failure is logged previously as an error in the Windows Event Log service. Restore the database or file from a backup, or repair the database.
From the error message it looks like we have the problem with one of the log entries, but if this is the case why are we able to restore same backups on different servers?
Our production server from where the backups are coming runs SQL Server 2014 Enterprise edition and has CDC enabled on 4 tables.
Our BI server on which I am trying to restore the backup runs SQL Server BI edition.
Is there any way to bypass this without disabling cdc? Unfortunately we are not allowed to disable this particular feature. I did my reading, but I was unable to find anything helpful.
The only way around that I see is to restore backup on another server, disable cdc and then back up new database and transfer backup to BI server. It more more complicated and hence more likely to break than direct backup transfer. If you see any better way please let me know. Any suggestions will be highly appreciated!

SQL Server 2014 restore .bak file

I am trying to restore a .bak file (might be created with SQL Server 2010) in SQL Server 2014 with this script
use master;
restore database [Vision] from disk = 'C:\Users\felix_000\Documents\Vision\db\Vision_db.bak'
with replace
and error log is as following:
Msg 5133, Level 16, State 1, Line 2
Directory lookup for the file "C:\SQLData\vision_newschema.mdf" failed with the operating system error 2(The system cannot find the file specified.).
Msg 3156, Level 16, State 3, Line 2
File 'Vision' cannot be restored to 'C:\SQLData\vision_newschema.mdf'. Use WITH MOVE to identify a valid location for the file.
Msg 5133, Level 16, State 1, Line 2
Directory lookup for the file "C:\SQLData\vision_newschema_log.ldf" failed with the operating system error 2(The system cannot find the file specified.).
Msg 3156, Level 16, State 3, Line 2
File 'Vision_log' cannot be restored to 'C:\SQLData\vision_newschema_log.ldf'. Use WITH MOVE to identify a valid location for the file.
Msg 3119, Level 16, State 1, Line 2
Problems were identified while planning for the RESTORE statement. Previous messages provide details.
Msg 3013, Level 16, State 1, Line 2
RESTORE DATABASE is terminating abnormally.
I tried with right click Tasks -> Restore -> Database, it told me that
Restore of database 'Vision' failed. BACKUP LOG cannot be performed because there is no current database backup. (Microsoft.SqlServer.SmoExtended)
Here are the methods I tried,
Run SSMS as administrator
change the file folder security property to FULL CONTROL
Be sure That you are not trying to restaure an Entreprise Edition's Back up on an Express Edition.

Litespeed error on RESTORE - works on 2005, fails on 2008

I have a 10 page procedure that will extract a litespeed compressed backup file (brought to Network shares from a different server) into 3 files, restores filelist and header; and then restores it to a local database. When I try to run the procedure on a SQL Server 2008 server it fails with the following error whereas when run the same on a SQL Server 2005 server, it runs just fine and restores it to the local database.
Error: Column name or number of supplied values does not match table definition.
Full error:
Extracting differential LiteSpeed backup into SQL Server backup files: Started
Extracting differential LiteSpeed backup into SQL Server backup files: Complete
Msg 213, Level 16, State 7, Line 1
Column name or number of supplied values does not match table definition.
Msg 3013, Level 16, State 1, Line 1
RESTORE FILELIST is terminating abnormally.
Msg 213, Level 16, State 7, Line 1
Column name or number of supplied values does not match table definition.
Msg 3013, Level 16, State 1, Line 1
RESTORE HEADERONLY is terminating abnormally.
Any thoughts on why it fails on SQL Server 2008?
Because the version of Litespeed you have (or your own stored procedure) is building a #temp table to dump the results of the RESTORE commands, and the code doesn't take version into account.
If you compare the 2005 documentation to the 2008 documentation for RESTORE FILELISTONLY, you'll see that 2008 added a new column called TDEThumbprint (there may be other changes; I didn't look very hard).
Similarly, comparing the 2005 docs to the 2008 docs for RESTORE HEADERONLY, there is an additional column called CompressedBackupSize.
The insert fails because the #temp tables being used to dump the results of this command are built for the 2005 version and are missing the additional column. SQL Server doesn't like it when a #temp table has 15 columns and you try to stuff 16 columns into it.
If it is your procedure that creates the #temp tables, you need to make your procedure branch depending on version, or create version-specific procedures, and use a table with the appropriate number of columns before running your insert.
If it is not your code, then you should talk to Dell/Quest about this. It's quite likely they have already fixed it, but you don't have the most recent version of Litespeed...

Resources