How to Repair a Corrupt Exchange Database?

Exchange Server heavily dependent on the Active Directory as all the configuration is stored in the Active Directory Schema. On the other hand, all the users’ data and other important items are stored in the Exchange Database (EDB) file. In addition, the Exchange Server uses Transaction Logs to temporarily hold information, until it is committed to the database. The transaction log files act as a buffer between the database and the requests from users or systems. If the transaction log files get damaged/corrupted or one of the files is missing, then the database will not be able to mount and the state of the database will be marked as Dirty Shutdown. Until the state is changed to Clean Shutdown, the Exchange Server will not allow you to mount the database, resulting in users not being able to access their mailboxes.

Some other factors or reasons, like human errors, sudden loss of power, malware infection, natural disasters, etc. can also damage your database. In such situations, restoring the database from backup would fix the problem but you will suffer data loss from when the backup was executed to when the issue has occurred. Another option is to repair the corrupted database. In this article, we will be going through the process of repairing the corrupt database in the Exchange Server setup.

How to Repair the Corrupt Database In Exchange Server?

In Exchange Server, the Extensible Storage Engine Utilities (ESEUtil) is a command-line tool that is used to check the database integrity and repair the databases. You can use the ESEUtil commands to repair an Exchange Server database or salvage the data. Let see the step-by-step process.

Step 1: Locate the Scripts and Commands

You need to first locate the scripts and commands. Usually, the location is <Exchange Server installation folder>\V15\Bin. If the installation is at the default path, open a command prompt with administrator privileges and run the following command.

cd “C:\Program Files\Microsoft\Exchange Server\V15\Bin”

Step 2: Check the Database Status

Next, you need to check the status of the database by using the MH switch with the ESEUtil command as given below:

eseutil /mh “M:\ExchangeDatabases\mydatabase.edb”

Note: Replace the path in parenthesis with the path of your Exchange Server database.

If the database or the supporting files are damaged, you should see the State as Dirty Shutdown. This means that the database needs to be repaired as it is not healthy to operate.

Step 3: Perform Database Recovery

There are two repair options – Soft Recovery and Hard Recovery. Soft Recovery is used in cases of small corruption issues in the database. This will try to restore the database to a consistent state without any data loss. To perform soft recovery, you can run the ESEUtil command with the R switch (see the below example).

eseutil /R “M:\ExchangeDatabases\mydatabase.edb”

Once the recovery process is completed, you can rerun the command with the MH switch to check the database state. If it shows the State as Clean Shutdown, then you can go ahead and mount the database.

If the above fails, you need to perform the hard recovery. However, you need to remember that the hard recovery process results in data loss. In hard recovery, anything which is deemed as corrupted will be purged from the database and there might be false positives. Depending on the damage, there will be data loss. So, it is important to backup the database before performing such operation. 

In addition, you need to have enough storage space (almost double) available as this operation creates a new database and you might end up with no space on the server. The operation will take some time to finish and cannot be stopped once started.

To perform hard recovery, execute the ESEUtil command using the P switch (see the below example).

eseutil /P “M:\ExchangeDatabases\mydatabase.edb”

When you execute the command, you will get a warning of data loss. You need to accept the data loss to proceed with the operation. After the process is complete, run the command with the MH switch to check the state of database. Mount the database if it is in Healthy Shutdown state.

After a successful repair of the database, it is suggested to create a new database and move all the mailboxes to the new database.

An Easy and Quick Solution to Repair Corrupt Exchange Database

When a situation arises, there is a lot of pressure on Exchange admins to get the services up and running within minimal downtime and no data loss. This means that every minute and every email counts for the business continuity. For quick recovery of data, you can rely on specialized Exchange database recovery software, such as Stellar Repair for Exchange. This tool is renowned for its performance and compatibility. It allows you to directly open Exchange Server databases from any version, of any size, and in any state. After a quick/deep scan, you will be able to view the entire structure of the database and then granularly export the recovered data to PST and other file formats. You can also use the tool to directly export the recovered user mailboxes, shared mailboxes, user archives, disabled mailboxes, purged/deleted items, and public folders, to a live Exchange Server database or Microsoft 365 tenant. This helps reduce the recovery time, while ensuring no data loss.

Best Practices to Follow

  • Before attempting to repair any database, it is imperative to take its backup.
  • Always check the Event Viewer to find out where the problem is.
  • Daily backups should be used to ensure that the transaction logs are committed. This helps reduce the risk of corruption and increase the chances of recoverability.
  • Monitor the services, operating system, performance, and storage of the server. This helps find the issue before more damage is caused.
  • Ensure that you have the right tools in hand that can help meet the company’s RPO and RTO and restore the services with minimal impact.
  • Set up Database Availability Groups (DAG) to ensure business resilience and disaster recovery.

Conclusion

Above, we have explained the process of repairing a corrupt database using the ESEUtil commands in the Exchange Server. This is a delicate process which would need precision. In addition, there are chances of data loss when performing hard recovery on the database. As an alternative solution, you can use an Exchange repair tool, like Stellar Repair for Exchange. This tool can easily repair the corrupt database and recover all the mailboxes and other items without any data loss. It can also export the recovered mailboxes and other items to a live Exchange database or Office 365 (Microsoft) account.