In SQL Server, the backups are usually stored in a file with .BAK extension. The backup comes in handy when you need to restore the data in case of an incident or issue with the server or database file. However, SQL database backup (.BAK) files can also get corrupted due to a range of factors. Below, we will discuss the common factors or causes for corruption in .BAK file in SQL Server.
Common Causes of .BAK File Corruption in SQL Server
Here we will list some possible reasons that can lead to corruption in the .bak file in SQL Server.
Power Outages
If you do not have a UPS (Uninterrupted Power Supply), then a sudden power outage can interrupt the backup process, resulting in the .bak file corruption. To avoid this problem, include a UPS for your server’s uninterrupted power supply.
Hard Disk Problems
If the hard disk has bad sectors where the backup is stored, then backup file can get corrupted. Another common problem is the disk controller failure. If the disk controller has problems, data corruption can occur. Therefore, it is suggested to regularly run the CHKDSK command to verify the disk status.
RAM Errors
During the backup process, sometimes, the data remains temporarily in memory. If the RAM has errors, the backup can get corrupted.
Make sure that you always have enough memory. You can verify the memory using System Monitor or Task Manager. Also, you can run the Windows Memory Diagnostic, included in the Windows operating system.
Network Errors
If there are network problems when moving the backup (.bak) file to a different server, the file can get corrupted. To avoid such problems, make sure to update your network drivers regularly. You can also use Quality of Service (QoS) applications to prioritize your traffic.
CPU Issues
If your CPU is overheating, you may face problems during the backup operation. This may lead to corruption in the backup file. To avoid these problems, do the following:
- Schedule the backup during no business hours (at night or weekends).
- Monitor your CPU consumption with the Performance Monitor, Task Manager, or any other tool of your preference. If you notice that the CPU is all the time at 90-100 %, you need to buy a better processor or a better server.
- If you notice that the CPU is all the time at 90-100 %, you need to buy a better processor or a better server.
Malware or Virus Attacks
Malware or virus can damage the backup files. It is common to receive malware or virus that can corrupt the backup files.
To safeguard against malware or virus attacks, make sure to install powerful anti-virus, anti-phishing, and anti-malware applications. Also, train the company staff about security to minimize such problems.
Solutions to Fix and Recover Corrupted Backup Files in SQL Server
First, verify if your backup is fine. For this, you can use the VERIFYONLY option with the RESTORE command. The following example shows how to do it:
RESTORE VERIFYONLY
FROM DISK = @BackupPath;
If your backup is corrupted, you may try to use another backup. If you do not have another backup or if it is obsolete, you can restore and repair the database by using the following command:
FROM DISK = 'C:\backups\stellardb.bak'
WITH REPAIR;
A Proven Solution to Restore Corrupt .bak File
You can use a third-party SQL repair software, such as Stellar Repair for MS SQL to recover data from corrupted backup files. There are three editions of this software – Corporate, Technician, and Toolkit. The Corporate edition, which is the basic one, does not have the feature to fix corrupted backups. However, the other two editions - Technician and Toolkit - have the option to fix corrupted SQL server backup files. The main differences between both versions are the prices. Also, there are two additional features in the Toolkit edition - Log Analysis and Database Format Conversion.
The following table shows the differences between the Technician and the Toolkit editions of Stellar Repair for MS SQL.
Feature | Technician | Toolkit |
Price | $399 | $499 |
Databases Limit | Unlimited | Unlimited |
Repair MDF and NDF files | Yes | Yes |
Recover all database components | Yes | Yes |
Reset passwords | Yes | Yes |
Extract data from corrupted backup | Yes | Yes |
Log Analysis | No | Yes |
Convert database format | No | Yes |
To recover data from the corrupted backup file, you need to download Stellar Repair for MS SQL and then install it.
You can browse and select your backup file or use the Find button to find the file.
You can then select the objects that you want to recover. You can restore the recovered data in an existing database or a new database. You can also save the data from tables in Excel, CSV, or HTML file.
Conclusion
Above, we have discussed some common causes of SQL database backup (.bak) file corruption. We have mentioned some proven solutions to fix the issue. If the manual solutions do not work for you, then you can use Stellar Repair for MS SQL to recover data from your corrupt backup file. The software is recommended by many MVPs and admins for recovering data from corrupt database files with complete integrity.