How to safely flush the Exchange transaction logs without interruption or downtime
Recently I had a migration from an Exchange 2007 server to an Exchange 2013 with a network attached LUN for storage.
After migrating all the users, over 200 mailboxes, the Logs folder was getting huge. The total space occupied by both the logs and databases was about 832 GB.
The logs folder reached somewhere around 430 GB.
So what are transaction logs?
Transaction logs are files approximately 1 MB in size, used for an eventual database restoration.
In event of a failure, if you ever need to restore a database, the transaction logs are very important pieces of the puzzle. But if they are not deleted, they tend to use up the space very quickly and this can result in filling up all the available space.
If so, then the databases get dismounted and all the users lose connectivity to their E-mail system.
There are 2 ways to deal with this problem.
First one is to enable circular logging on every database. This means that Exchange will tend to overwrite the logs rather than continuously write logs to the disk. But to enable circular logging you have to dismount and remount databases. If this might seem a convenient approach, it’s not the easiest to do, because on E-mail systems with hundreds or even thousands of mailboxes, downtime is unacceptable.
The second way is to have a backup solution which backs up the Exchange databases. After a successful backup the backup bit is reset and Exchange deletes the transaction logs, because they are not needed anymore. The databases are backed up.
But what if you don’t have a backup solution in place?
The same thing in my case, I did not have a backup solution just yet for the Exchange server and logs were being added really fast.
The solution I used was to “trick” Exchange server into thinking the databases were backed up.
Enter Diskshadow.
Diskshadow makes a shadow copy of the hard drive and this acts just like a backup.
To use diskshadow you need to open a Command Prompt window with elevated privileges. Right click and click Run as Administrator.
After the command prompt window is open type diskshadow
Another window opens with the diskshadow prompt.
You need to add the volume into which the databases and logs reside. In my case it was the D: drive.
After that you have to launch the Begin backup command. Then type create, and after the operation completes, type End backup.
The result was that the logs were flushed and available space decreased. From a staggering 430 GB the logs folder was approximately 427 MB (that’s megabytes)
The drive free total space was also increased.
So to sum things up in a nutshell:
Open a command prompt -> diskshadow -> add volume d: (or whatever yours is)
-> begin backup -> create -> end backup
This is a reliable and safe way to flush (purge/delete) the Exchange transaction logs.