Office 365 DirSync Database Running Out of Space? Automate Cleanup of Run History

Posted on Updated on

As you start using the Office 365 Directory Synchronization application, providing administrators the ability to manage users, contacts, groups and Active Directory attributes and values, all from your local Active Directory.  These updates/changes will be synchronized into your Office 365 tenant, keeping the two Active Directories synchronized.

Directory Synchronization runs, by default, every 3 hours, synchronizing all changes found within the local Active Directory.  Each run saves a history of the runs and over time your DirSync database will run out of space, due to saving these run histories.

Manage your Directory Synchronization

PROBLEM STATEMENT

You are running the Office 365 / Directory Synchronization tool with a SQL Server Express backend.  You have less than 50,000 users.  Now, you are seeing information in the Application Event Log indicating that the database is full.

CAUSE

The reason this happens, is because each run is logged on the Operations tab of the MIISCLIENT.EXE console.  This is commonly referred to as the Run History.  If there is no process to clean up the run history, then it will continue to grow, and the MDF file of the SQL Server Express database will grow as well until you reach the 10GB limit.

RESOLUTION

To resolve the issue, you will need to clear the run history.  To prevent the issue from happening, you may need to build a script that can be called from Task Scheduler to clear the run history.

Clear Run History

Use the following steps outlined in this TechNet article to clear your Directory Synchronization Run History and keep your DB at a manageable size:  http://social.technet.microsoft.com/wiki/contents/articles/7034.how-to-clear-the-run-history.aspx

GOAL

The goal of this article is to provide information on a good and common question, “How do I clear the run history?” to be able to reduce the size of my MDF / LDF files.

As many of us already know, if we do not clear the run history, then we run into issues such as

  • Performance of Synchronizations
  • Performance of moving between Management Agents and Operations tabs in the Synchronization Server Console.
  • Size of the MDF file has grown to extreme

This article has been compiled to help provide information on how to clear the run history.  We do provide several ways to clear the run history.  Let’s talk about them now.

MANUALLY

In the MIISClient.exe GUI, found in c:\Program Files\Microsoft Online Directory Sync\SyncBus\Synchronization Service\UIShell\MIISClilent.exe, while viewing the run history on the Operations Tab, you can select from the Actions menu, “Clear Runs”.

In doing so, you will receive a dialog with a few choices.

  1. Clear All Runs: This will clear everything you see on the operations tab, essentially the run history.
  2. Clear Runs Before: This allows you to pick a date and time to remove that date and time and previous to that date and time.  It allows you to be able to keep some of the run history.
  3. Save runs before clearing them:  This box is checked by default.  It allows you to dump the run history to an XML file.

Once you configured how you want to clear the run history, you simply click Ok and then wait for it to finish clearing the run history.

 SCRIPT

The Synchronization Service engine has a WMI Provider that allows you to interface with the Synchronization Service Engine via WMI.

MSDN provides a great resource using the WMI Provider to build a script using VBSCRIPT and/or PowerShell.

MIIS_SERVER is the WMI Class that you will start with when building your script.

ClearRuns Method is the method that you will utilize to clear the runs.

Example Script to Clear Runs
Clear Run History Script
Dim Service

Dim ManagementAgent

Dim DeleteDate

Set Service = GetObject(“winmgmts:\root\MicrosoftIdentityIntegrationServer”)

Set Server = Service.Get(“MIIS_Server.Name=’MIIS_Server1′”)

‘// DeleteDate the date to use for the deletion of runs

DeleteDate = GETDELETEDATE( Date() – 1 )

WScript.Echo “Deleting Run Histories from ” & DeleteDate

WScript.Echo “Result: ” & Server.ClearRuns(DeleteDate)

‘// ======================================================================

‘// FUNCTION IIF

‘// PURPOSE: To be able to execute an If…Then…Else statement on a single line

‘// — conditionalString: is the conditional statement to check via the IF

‘// — TrueString: if the condition is true, the statement to execute

‘// — FalseString: if the condition is false, the statement to execute

‘// ======================================================================

FUNCTION IIF(conditionalString, TrueString, FalseString)

IF conditionalString THEN

IIF = TrueString

ELSE

IIF = FalseString

END IF

END FUNCTION

‘// ====================================================================

‘// FUNCTION GETDELETEDATE

‘// PURPOSE: The date has to be formatted in a special way to work with the sync engine.

‘//     using this function to help format the date.

‘// ====================================================================

FUNCTION GETDELETEDATE( TheDeleteDate )

GETDELETEDATE = YEAR(TheDeleteDate) & “-” & IIF(LEN(MONTH(TheDeleteDate))=1,”0″ & MONTH(TheDeleteDate), MONTH(TheDeleteDate)) & “-” & IIF(LEN(DAY(TheDeleteDate))=1,”0″ & DAY(TheDeleteDate), DAY(TheDeleteDate))

END FUNCTION

RESOURCE KIT FOR MICROSOFT IDENTITY INTEGRATION SERVER 2003

If you have a version of the Synchronization Service Engine prior to Microsoft Forefront Identity Manager 2010, then you can utilize the Resource Kit for Microsoft Identity Integration Server 2003 and the MIISCLEARRUNS.EXE utility.

Download the Resource Kit 2.0 for the Microsoft Identity Integration Server 2003

QUESTIONS

How can I automate the clearing of the run history?

This is actually a great question.  You will need to write a script that does the clearing of the run history.  Once you have the script compiled utilize Task Scheduler to have the script run at a specified time.

How often should I clear the run history?

The answer to this question is based on your business rules for your current identity solution.  Keep in mind, that every time a run profile is executed, a record is added to the run history.

An example, if you have 2 management agents.  You run Full Import (Stage Only) on both, Full Synchronization on both, Export on both, and Confirming Delta Import on both Management Agents.  You execute this cycle every 30 minutes.

2 Management Agents x 4 Run Profiles = 1 cycle = 8 Records in the Run History every 30 minutes

Whatcha thinkin?

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s