Home Purge Transaction Logs Manually in Exchange
Post
Cancel

Purge Transaction Logs Manually in Exchange

Table of Contents


The correct way to flush/clear the Exchange logs is to perform a backup of the mailbox database in question, with an ‘Exchange aware’ piece of backup software. This will clear down the logs properly. *** Why Do We Need Logs? If there’s a problem, and we lose the database, we can ‘play’ the log files back into the database to restore any messages that were ‘lost’. Because you restored from a backup taken at 10:00 pm hours last night, and it’s now 10:00 am hours the following morning. The logs let us get the email that came in after the backup had finished. This is why, after a successful backup, the logs are usually cleared.

So your backup isn’t, and It’s filled up with logs and taken the database down (dismounted). Now there’s a ton of logs and need to clear them.

Run following command from Exchange Management Shell as elevated:

1
Set-Location $EXScripts
1
.\eseutil.exe /mk C:\ExchangeLogs\DB01\DB01\E01.chk

The command will change depending on which database you are checking. The “chk” file will change names as well, you will need to go into the log directory for the particular database and check what the “chk” filename is, and put that in the command, eg: ***

1
2
.\esentutl.exe /mk "C:\ExchangeLogs\DB02\DB02\E09.chk"
.\esentutl.exe /mk "C:\ExchangeLogs\DB03\DB03\E11.chk"

The output of the command will be something like:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.
 
Install the latest PowerShell for new features and improvements! https://aka.ms/PSWindows
 
PS C:\Users\davidmarker> Set-Location $EXScripts
 
PS C:\Program Files\Microsoft\Exchange Server\V15\Bin> .\eseutil.exe /mk C:\ExchangeLogs\DB01\DB01\E01.chk

Extensible Storage Engine Utilities for Microsoft(R) Exchange Server
Version 15.00
Copyright (C) Microsoft Corporation. All Rights Reserved.

Initiating FILE DUMP mode...
      Checkpoint file: C:\ExchangeLogs\DB01\DB01\E01.chk

      LastFullBackupCheckpoint: (0x0,0,0)
      Checkpoint: (0x132B33,F0,0)
      FullBackup: (0xF494C,FE,DA5)
      FullBackup time: 04/14/2020 11:56:07.196
      IncBackup: (0x0,0,0)
      IncBackup time: 00/00/1900 00:00:00.000
      Signature: Create time:03/31/2020 21:11:30.134 Rand:1030499006 Computer:
      Env (CircLog,Session,Opentbl,VerPage,Cursors,LogBufs,LogFile,Buffers)
          (    off,   1000, 100000,  16384, 100000,   2048,    256,  65535)
      1 C:\ExchangeDatabases\DB01\DB01.edb LogOff VerOn RW
        dbtime: 576505988 (0-576505988)
        objidLast: 92469
        Signature: Create time:03/31/2020 21:11:30.197 Rand:3200906174 Computer:
        MaxDbSize: 0 pages
        Last Attach: (0x6D1F2,2,268)
        Last Consistent: (0x6D1F1,7E,FA4)
        
PS C:\Program Files\Microsoft\Exchange Server\V15\Bin> 

The line to check is “Checkpoint”. This line tells us the filename of the last committed transaction file, eg “0x0535C8”.

You then need to go to the logs directory of the database, sort the logs file by date (very important), and find the matching file name. See below, you can see the filename that ends in “535C8”.

File Explorer of Log Files

That should mean you can safely delete any older log files than the one shown by the command. But at this point in time, I would use these instructions to confirm that everything from the 5th and 6th of September has been committed and only delete logs files time-stamped from the 5th and 6th. Please also ensure you are only deleting log file files and nothing else.

If the commands confirm that logs files from today (7th) are committed, then it should be fine to delete the ones from the 5th and 6th. ***

Please Note: Their other files and folders there are contained in the logs directory, so please ensure you only delete log files. ***

https://www.microsoft.com/en-us/download/details.aspx?id=8725
https://techcommunity.microsoft.com/t5/exchange-team-blog/repairing-exchange-databases-with-eseutil-when-and-how/ba-p/610276
This post is licensed under CC BY-SA 4.0 by David Marker