ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

Main Area and Open Discussion > General Software Discussion

recover an SQL .mdf file that is currently written to a bad sector

(1/3) > >>

questorfla:
That is as best as i can explain it.  The company who wrote the software is notorious for being UNhelpful.  They connected and told me the problem we had were due to a "xcorruption" of the Logs file so nothng to worry about.  He fixed that and left paying NO attention to the Other Windows error logs I was trying to indicate that said Urgent Warning Bad Sector replace drive.
Anyway, his proof was that their program was working again.  AND it also starting making its own backups again (It had stopped which is why i called).  BUT  their backups are proprietary and i cannot recover from them or even see what is in them.

If the data is STILL in a bad section of the hard-drive and Windows is still telling me to get it out/fix it/replace the drive etc and i ignore those warnings it would be my fault if something ever happened. (or that is how I see it)

I have tried every tool i have (which isn't a lot) and I can copy every file in the DATA folder in that SQL instance, except the one that matters the most.  The  .mdf file which is 2,315,904KB and it cannot be copied due to a cyclic redundancy error.
I was able to get it copied by zipping it and copying the zip, but when unzipped I  am left with 2,181,760KB file size  which I presume means something got left out.  The DB is so large that if left where it is, it will continue to grow but the backups will all be bad.
While their tech may be comfortable with leaving it on a system with Windows screaming to replace the drive, I am not so warm and fuzzy about that.

Shades:
While I'm not a fan...try if you can use CHKDSK, in the off chance Windows is actually able to repair the bad sector(s) or capable of moving data around to spare sectors.

Then I would try software such as TestDisk to retrieve data. At least it doesn't give up that quickly as Windows explorer when copying files. UnstoppableCopier is another piece of software that won't give up easily when copying files. Both are free to use.

If you don't trust the hard disk to last much longer, you might be better off to clone the current hard disk to a new (similar storage capacity or bigger) hard disk, disconnect the current hard disk to keep the original data as safe as possible and try to retrieve data from the cloned hard disk. This way is likely best, as you will need a new hard disk for your server anyway. And with cloning you have a 1-on-1 copy, so the server should work immediately after the cloning is finished and the original HD is disconnected. Especially when you can get a new hard disk that is the same brand and model as the original.

If you have more than one SQL Server running, you could dump the original database and import it in the other SQL Server. That would be fastest and give you an option to check for content and/or structural differences between both databases and make fixes where necessary. Which is also not hard to do with the software that comes with the server software. As your database is only 2.3 GByte in size you can download the free SQL Server 2012 Express software, with which you are allowed to run a database smaller than 10GByte. There might be already an express edition from SQL Server 2014 available, if you fancy the latest.

And as a general rule: always verify if your dumps are correct...don't trust the message saying the dump was created successfully, but upload it again and actually check for errors during import and do random checks for structural and/or content integrity. I have been burned by dumping Oracle databases that show no error in the dump log file, but still are capable of generating import errors. This hardly ever happens, so if you feel lucky, go without the verification...but don't say you weren't warned.

Making backups/dumps from a MS SQL Server database is quite easy and fast. At least it is on my MS SQL 2012 Server with the management software that comes standard with the server software. PowerShell is very handy too when making SQL database dumps.

4wd:
While I'm not a fan...try if you can use CHKDSK, in the off chance Windows is actually able to repair the bad sector(s) or capable of moving data around to spare sectors.

Then I would try software such as TestDisk to retrieve data. At least it doesn't give up that quickly as Windows explorer when copying files. UnstoppableCopier is another piece of software that won't give up easily when copying files. Both are free to use.-Shades (June 21, 2015, 12:51 AM)
--- End quote ---

Would it be a good idea to make a sector clone of the HDD before using a recovery program?

Shades:
Further in my comment you will find the same statement...which applies when questforfla is of the opinion that the hard disk won't survive too long anymore.

On the other hand, there is not much harm in using CHKDSK if the hard disk performs as expected, except for one or more sectors. That was the impression I got after reading his first post, so I mentioned that first. Then again, I might have missed something, as English isn't my native language.

4wd:
Further in my comment you will find the same statement...which applies when questforfla is of the opinion that the hard disk won't survive too long anymore.-Shades (June 21, 2015, 12:07 PM)
--- End quote ---

Yes, sorry, should have made it clearer.  I meant make the clone regardless of what recovery software ends up being used - looking back over his posts I was wondering whether this is a new fault or something that's been building up over the last few months, eg.

[2015-03-30] https://www.donationcoder.com/forum/index.php?topic=40549.msg378792#msg378792
I have a need to temporarily use something other than the DB's internal backup of a SQL Express DB.  It normally runs its own backup  every night and i keep copies of what it backs up.   Unfortunately, it is having issues of some kind and until they can resolve them I would like to be able to keep some kind of backup even if it isn't the one they normally keep.
--- End quote ---

Navigation

[0] Message Index

[#] Next page

Go to full version