You are on page 1of 16

Flush Transaction Logs in Exchange

This article applies to all versions of Exchange from 5.5 to 2010.


The following knowledge base article gives you all the fruit about flushing transaction logs but I
assume you just want to know how to do it right?
http://support.microsoft.com/kb/240145
Your Exchange Logs get deleted when your database backup completes. When your exchange
server receives an email it dumps the email to the transaction logs. When the exchange server
free's up it then plays these logs into the database. Sometimes Exchange may not have played all
the log files into the database, so you cant simply "delete" them.
1. Dismount the all Exchange Mailbox Databases under the Storage Group you wish to clean up.
2. Use the ESEUTIL program to view if all the logs have been played into the Exchange
Database.
eseutil /MH database.edb

If all the databases are in a Clean Shutdown or Consistent state, you may remove all the
transaction logs. Older versions say "Consistent", New Versions of Exchange say "Clean
Shutdown". In my screenshot I'm using Exchange 2010.
Note: If it is not in a "Clean Shutdown" or "Consistent" state, you can use eseutil to reply
the log files into the database or remount the database and allow Exchange to replay them.
Caution: Do not delete log files if the state is not "Clean Shutdown" or "Consistent" as you
will loose email!

3. Delete all log files including the chk file. The checkpoint file keeps track of which log files
have been and have not been played into the database. Since there are no log files anymore, the
checkpoint is not needed.
Caution: If your database is in the same directory as your log files be careful you dont
accidently delete your edb database file as well!
4. Re-mount your exchange databases in your storage group. This will automatically create a
new checkpoint file ready to go!

The proper way to clear your log files is to take a full backup och the Exchange database or
to enable circular logging. But, you can also use the following method to clear the logs.
Dismount the databases, verify the databases are showing "Clean shutdown". Then
run ESEUTIL /MH on them and after that you can delete all the tran logs, restart the the
MSExchangeIS service and mount the databases.
Have a look here for a more detailed description:
http://clintboessen.blogspot.com/2010/09/flush-transaction-logs-in-exchange.html
http://support.microsoft.com/kb/240145
And yes, you should also delete the chk files.

How to manually purge Exchange server logs


clean and easy
Now heres a nice method to fake a full backup or an on-demand transaction logs purge
when you see you will be soon out of space, using the Exchange VSS writers and the diskshadow
utility (available with Server 2008 or 2008 R2) . This procedure also proves that a VSS backup
for your Exchange Server will work fine.
note: This method was tested on an Exchange server with Locally Attached Disks, not
storage attached LUNs.
Use this method on on your risk. You should preform a Full Backup right after this
process is done.
This example will show you how to purge the logs for a database that is located on Drive D. we
will fake backup drive D and this will trigger the logs to be purged.
1. Open Command prompt
2. Launch Diskshadow
1. Add volume d:
2. Begin Backup
3. Create

4. End Backup
3. At this step you should notice the following events in the application log indicating that
the backup was indeed successful and logs will now be deleted.
Heres some screenshots from the process:

The Diskshadow example screenshot.

ESE Event ID 2005 Starting a Full Shadow Copy Backup

MSexchangeIS Exchange VSS Writer preparation.

ESE Event ID 224 Logs are now purged

MSExchangeIS Event ID 9780 Backup is now complete.


side note: although this example was tested against Exchange 2010, it should work just as fine
with Exchange 2007.
Hope this helps you !

Performing Maintenance on DAG Members


in Exchange 2010 SP1
by Mike Pfeiffer on August 27, 2010
Exchange 2010 SP1 includes a few new scripts that you can use to make DAG member
maintenance a breeze. Its a simple process; you run a script to put a DAG member into
maintenance mode, moving the active databases off the server. After maintenance has been
completed, you run another script to take the server out of maintenance mode and then you can
redistribute the databases across the DAG. The process is outlined in detail below.
1. Run the StartDagServerMaintenance.ps1 script to put the DAG member in maintenance
mode
When you run this script, it moves all the active databases to other DAG members. It pauses the
node in the cluster, and sets the DatabaseCopyAutoActivationPolicy mailbox server setting to
Blocked. The Suspend-MailboxDatabaseCopy cmdlet is run for each database hosted by the
DAG member, and the cluster core resources will be moved to another server in the DAG if
needed.
[PS] C:\Program Files\Microsoft\Exchange
Server\V14\scripts>.\StartDagServerMaintenance.ps1 -serverName adatum-ex1

2. Run the StopDagServerMaintenance.ps1 script to take the DAG member out of


maintenance mode
After maintenance is complete, run this script to take the server out of maintenance mode. It will
run the Resume-MailboxDatabaseCopy cmdlet for each database its hosting, resume the node in
the cluster, and set the DatabaseCopyAutoActivationPolicy setting to Unrestricted.
[PS] C:\Program Files\Microsoft\Exchange
Server\V14\scripts>.\StopDagServerMaintenance.ps1 -serverName adatum-ex1

You can run these scripts remotely from another server with the Exchange tools installed and
specify the DAG member using the serverName parameter. Just make sure that the server you are
running the scripts from has the Windows Failover Cluster Management tools installed.
3. Run RedistributeActiveDatabases.ps1 script to re-balance the active database copies
across the DAG
Finally, you can run this script to redistribute the active mailbox databases across the DAG.
There are two options for balancing active database copies within a DAG: by activation
preference and by site and activation preference.

[PS] C:\Program Files\Microsoft\Exchange


Server\V14\scripts>.\RedistributeActiveDatabases.ps1 -DagName DAG
-BalanceDbsByActivationPreference -ShowFinalDatabaseDistribution -Confirm:$false

When using the BalanceDbsByActivationPreference parameter the script tries to move the
databases to their most preferred copy based on activation preference, regardless of the AD site.
If you use the BalanceDbsBySiteAndActivationPreference parameter, the script will attempt to
active the most preferred copy and also try to balance them within each AD site.
There are a number of parameters that can be used with this script. Run get-help
.\RedistributeActiveDatabases.ps1 for more details. Also, all of these scripts are documented in
Managing Mailbox Database Copies and Managing Database Availability Groups on TechNet.

Windows Server Backup with Volumes that


Include Active and Passive Exchange
Databases
by Mike Pfeiffer on October 3, 2010
By default, Windows Server Backup (WSB) does not support backing up a volume that contains
both active and passive DAG database copies. As you may know, WSB backups for Exchange
2010 are done at the volume level; the entire disk holding your database and its log stream needs
to be selected in order to perform a successful Exchange backup. If you have a combination of
both active and passive DAG database copies on the same volume, your backup will complete
with errors and an Event ID 9782 will be written to the application log:

Exchange VSS Writer (instance 4ad258c8-4b21-4236-94e3-4582747f062e:1) has completed the


backup of database DB1 with errors. The backup did not complete successfully, and no log files
were truncated for this database.

Fortunately, there is a setting that can be changed to allow you to perform successful backups
when a volume contains both active and passive databases. This is accomplished by disabling the
Exchange Replication Writer via the registry, forcing the Store Writer to be used instead. This
will ensure that you can get a good backup of the active database and the passive database will
be ignored. To enable this setting, perform the following steps:
1. Navigate to
HKEY_LOCAL_MACHINE\Software\Microsoft\ExchangeServer\v14\Replay\Parameters
2. Add a new DWORD value named EnableVSSWriter, and set its value to 0, as shown below:

3. Exit Registry Editor and then restart the Microsoft Exchange Replication service.
At this point, you can run your backup job on the volume that contains the active and passive
Exchange databases. Once completed, the status should indicate that the job finished successfully
and an Event ID 9827 will be written to the application log:

Exchange VSS Writer (instance 23e95ab1-bd0f-43de-b3f8-f437c36f5b05:2) has successfully


completed the full or incremental backup of replicated database DB1. The log files will be
truncated after they have been replayed.
For more details on backing up Exchange 2010 with WSB, check out my previous post, and also
see Understanding Backup, Restore and Disaster Recovery on TechNet.

Backing Up Exchange 2010 using Windows


Server Backup
by Mike Pfeiffer on March 11, 2010
You can use Windows Server Backup (WSB) to create Volume Shadow Copy Service (VSS)
based backups of your Exchange 2010 databases. If you havent worked with WSB to backup
Exchange databases, there are a few things youll want to be aware of before setting this up:

Backups are done at the volume level to perform a successful Exchange backup, you
have to backup the entire volume containing the databases and logs.
o
No remote backups you have to run WSB locally on the server you are backing up.
o
Only active DAG databases are supported you cannot backup volumes containing
passive copies of databases.
In this post well go over installing WSB on a Windows Server 2008 R2 server, and configuring
WSB to backup active Exchange databases in a DAG.
o

Installing Windows Server Backup


First, import the ServerManager module using the Import-Module ServerManager command:

Then we can add the backup feature using the Add-WindowsFeature Backup command:

Note: Only install the Backup feature, do not install the WSB command-line tools.

Performing a Backup
Start WSB, in the select Backup Once in the Action menu:

On the next screen, Different options and click Next:

Choose Custom for the backup configuration and click Next:

On the Select Items for Backup Screen, click Add Items:

In this example, my Exchange database and logs are stored on the E:\ drive. I am going to select
only the E:\ drive and click Ok.

Next, click on Advanced Settings:

On the VSS Settings tab, select VSS full Backup:

On the Specify Destination Type screen, I am going to choose Local drives because I have
another local dedicated disk for storing backups. You can use a remote file share, if needed:

Now, Ill select my backup destination and click Next:

Click the Backup button to perform the backup:

If everything goes OK, the backup will be successful, as shown here:

We can check the properties of the database in EMC to confirm that the database shows the Last
full backup date:

You can also check this value in the Exchange Management Shell using the following command:
Get-MailboxDatabase DAGDB1 -Status | select LastFullBackup

As you can see, it is a pretty simple process to backup Exchange databases using WSB. In an
upcoming post, Ill go over how to restore a database from a backup.

Related Posts

Windows Server Backup with Volumes that Include Active and Passive Exchange
Databases (1)
Restoring Mailbox Data from a Recovery Database in Exchange 2010 SP1 (62)

Windows Server 8 Developer Preview and PowerShell v3 First Look (7)

Office 365: Connecting to Exchange Online with Remote PowerShell (26)

PowerHour Webcast on 5/23/2012: Managing Office 365 with PowerShell (1)

You might also like