DB Defrag and Repair Process
DB Defrag and Repair Process
1. If we have deleted a large amount of data out o the store and want to reclaim the hard
drive space for whatever reason. This includes situations when databases reach the 16 GB
limit on Standard versions of Exchange server.
2. When we add more no of new users due to a merger or acquisition or when we delete
many objects from the store it can be necessary to do an offline defrag.
2. If we had to run a hard repair of the database ( eseutil /p - and that's another thing that
we do NOT recommend unless this is a last possible thing to do). After running a repair,
you should always offline defrag the database to get a new database file that has not been
repaired.
3. If we are experiencing a specific issue and have found a reference that says offline defrag
will fix it.
4. If we are working with PSS and resolving the issue requires an offline defrag.
5. As a general rule, only defrag to reclaim space if we're going to reclaim more than 30% of
the space. we can look for Event 1221 after nightly online defrag to get a conservative
estimate of how much free space is in the database.
What really happens when we do an offline defrag:
1. We need downtime to take your databases offline in order to run ESEUTIL on them.
2. Defrag actually works by reading the original database, and copying used database pages
into the brand new database file. When that is all done, we actually delete the original
database file and rename the new one and copy it into original database file's place.
3. Not only are the used pages read, but they are renumbered /recheck summed too. All
secondary indexes in the database are discarded as well.
Event ID 1221:
Event: 1221
Source: MSExchangeIS Public
Type: Information
Category: General
Description: The database "<storage_group>\<mailbox_store> (<server_name>)"
has <nnn> megabytes of free space after online de fragmentation has terminated.
2. ESEUTIL Filedump Mode:
We can do a space dump with ESEUTIL /MS to determine the space.
2.
The Eseutil utility can perform an offline defragmentation, which releases unused hard drive space
from Exchange Server databases to the file system.
References:
how to run defrag:
http://technet.microsoft.com/en-us/library/aa998863%28v=exchg.80%29.aspx
http://technet.microsoft.com/en-us/library/aa996139%28v=exchg.65%29.aspx
Database repair:
http://support.microsoft.com/kb/259851
http://support.microsoft.com/kb/192185
http://support.microsoft.com/kb/328804
http://support.microsoft.com/?id=255035
Applies to: Exchange Server 2007 SP3, Exchange Server 2007 SP2, Exchange Server 2007 SP1,
Exchange Server 2007
Topic Last Modified: 2006-12-20
This topic explains how you can use the Exchange Server Database Utilities (Eseutil.exe)
defragmentation command to defragment and compact an Exchange database offline. For more
information about using the Eseutil /D command, see Eseutil /D Defragmentation Mode.
Before You Begin
Before you perform the following procedure on an Exchange server that has a Mailbox server role, a
Hub Transport server role, or an Edge Transport server role installed, note the following:
Make sure you log on by using an account that is delegated membership in the local
Administrators group on that computer.
Make sure you have free disk space equal to 110 percent of the end size of the database that you
want to process.
Note:
You only need as much extra logical drive disk space as the final size of the files after
defragmentation. To get an approximate estimate of the database (mailbox or public folder
database) file size after defragmentation, look at application event ID 1221. This will tell you
how much free space is in the database file. From the current database size, subtract the amount
of free space specified in event ID 1221 to determine the approximate end size of the database
after defragmentation. Although it is impossible to precisely predict how much disk space will
be reclaimed, you should leave a recommended 110 percent of free disk drive space. Similar to
how the mailbox or public folder database generates event 1221 to report logical free space
after an online defragmentation, the Microsoft Exchange Server 2007 Edge Transport or Hub
Transport server Queue database files also generate an event ID 7007 that reports logical free
space after an online defragmentation. In addition, Queue databases on the Exchange 2007
Edge Transport or Hub Transport servers generate event ID 7006 to report logical free space
before the online defragmentation. The source for these events is MSExchangeTransport.
Dismount a mailbox or public folder database before defragmenting. During an offline
defragmentation, the dismounted mailbox or public folder database will be inaccessible to
clients. Before performing an Eseutil defragmentation on a transport Queue database (Exchange
2007 Edge Transport or Hub Transport server database), stop the Microsoft Exchange Transport
Service on the server. In addition, because the Queue database is offline during
defragmentation, messages from the Queue database will not be delivered through the Hub
Transport or Edge Transport server.
Procedure
To defragment an Exchange database on a mailbox server
1. In the Exchange Management Console, right-click the database that you want to defragment,
and then click Dismount Database.
Note:
The default storage group name is First Storage Group, and the default database name is
Mailbox Database, so the default path is C:\Program Files\Microsoft\Exchange
Server\Mailbox\First Storage Group\Mailbox Database.edb.
Use the following database switch to run Eseutil defragmentation on a specific database:
Eseutil /d <database_name> [options]
Note:
This command can be valuable because it leaves the original database in place and does not
write over it. This option increases the amount of available disk space required for
defragmentation. This is because you will need space for two additional copies of the Exchange
database.
To defragment the Exchange database but have the temporary file on another logical drive, from
the command prompt, run the following command:
eseutil /d <database_path_and_file_name> /t
<temp_database_path_and_file_name>
Note:
If the logical drive is accessible over a network connection, this can affect the amount of time
that it will take defragment the database.
To defragment an Exchange database on a Hub Transport or Edge Transport server
1. To dismount the Queue database, from the Services snap-in, stop the Microsoft Exchange
Transport Service.
2. At the command prompt, point to the <Exchange install folder>\bin location.
Note:
<Exchange install folder> is the folder where you installed Exchange. The default location is
\Program Files\Microsoft\Exchange Server.
3. Type the Eseutil /D command, a database switch, and any options that you want to use. For
example, the following command (all in one command) runs the standard defragmentation tool
on a transport Queue database:
Eseutil /d c:\program files\exchange
server\TransportRoles\data\queue\mail.que
Note:
The default name of the Queue database is mail.que.
Event 1221
Space Management in the .stm File
Database Space Tree Dump (Eseutil /ms)
Why Do Exchange System Manager and Outlook Show Different Sizes for the Same Mailbox?
For More Information
Event 1221
When you receive Event 1221, you see the following:
Event: 1221
Source: MSExchangeIS Public
Type: Information
Category: General
Description: The database "<storage_group>\<mailbox_store>
(<server_name>)" has <nnn> megabytes of free space after online
defragmentation has terminated.
Note:
Even though the event shows "terminated," this is an expected behavior.
The number of megabytes (MB) of free space presented is derived from the number of free pages that
are available at the database root, messages tables, folders tables, and attachments tables. Statistically
these tables represent nearly 90 percent of the space used in the database.
To understand the reason for this, a review of database space management is needed. Consider the
following:
The fundamental space allocation in Exchange is a 4 kilobyte (KB) page.
A series of 16 consecutive pages is the amount of space that is allocated to a table when space is
requested. Exchange does not allocate one page at a time.
A page cannot store data from two different tables or belong to two different trees.
There are two levels of space management that occur in the database. One is at the global database
level, which is the space available to all tables in the database store in ranges of 16 consecutive pages,
and the other is at the b-tree level. If you are unfamiliar with the concepts of B+trees, it may be easier
to think of them as a table. Tables maintain the state of pages they own and do not free up pages to the
overall database until a 16 consecutive block of pages is freed. The reason for this is efficiency. By
reusing pages that are physically adjacent to existing pages, you minimize the effort necessary to
perform read and write operations. So by holding onto pages, you ensure that a larger majority of pages
for a specific table are physically adjacent.
In a database, you can have thousands of tables, at least one for each folder in every mailbox. As
previously mentioned, statistically the messages tables, folders tables, and attachments tables represent
90 percent of the space used in the database. These tables have the greatest percentage of free space,
commonly referred to as white space, in the database.
To arrive at a calculation for the amount of available space an individual table possesses, you must
interrogate the space usage information of the table. If you were to do this for thousands of tables, it
would take a large amount of time to perform this calculation. As a result, Microsoft considers only the
available space of the message, folder, attachment, and database root when logging Event 1221.
The database contains additional information that is not part of the mailbox allocation. For example,
there are search folders, indexes, and system tables that are required for Exchange to operate. In
addition, a page cannot belong to multiple tables. If a page has free space, it can only store new records
for that table, and it will only contain records that meet the criteria to be stored on that page. If you
stored every record beginning with the letter A on one page and every record beginning with B on a
second page, there is no reason that a record beginning with A should appear on the page containing all
the B values. Therefore, there can be space available on an individual page that is not taken into
consideration when calculating Event 1221, because Event 1221 only adds the empty or free pages in
the tables mentioned previously.
Online defragmentation compresses records to fewer pages in a particular table. For example, if a table
owns 100 half-full pages, online defragmentation will attempt to free approximately half of the pages.
When 16 contiguous pages are freed, the space is released to the database to be used by other tables. It
is only the pages that are freed in the previously mentioned tables that eventually get reported.
Space Management in the .stm File
Space management for the .stm file is different from the logic in the .edb file. In the .stm file, data is
still arranged in 4 KB pages, however, the page state information is not maintained in the .stm file. This
is done in the .edb file. Pages in the .stm file have four primary states:
Free Currently does not contain data and is available to accept new incoming data.
Reserved Has new data from an inbound message, but has not been committed.
Committed Contains data currently referenced by records in the .edb file.
Deleted A page that is being freed, but is not ready to accept new data.
Inside the .edb file, two tables exist to manage the contents of the .stm file, SLVAvail and
SLVSpaceMap. In the .stm file, which is referred to as the SLV file in Extensible Storage Engine (ESE)
source, space is managed in 512 page chunks. In the SLVAvail table, entries are maintained for each
512 page chunk. Two bits are used to describe the state of each page in the 512 page chunk. When a
new space request is received, which is a new incoming Simple Mail Transfer Protocol (SMTP)
message, this table is queried to locate space in the .stm file to store the message. A series of pages is
returned to SMTP in the form of a file handle.
The SLVSpaceMap table allows for reverse lookup of pages in the database to map to a particular table,
row, and column that references a particular page in the .stm file. It also records the checksum of a page
in the .stm file.
Database Space Tree Dump (Eseutil /ms)
If you want a more in-depth look at the space used in the database, a space dump using Exchange
Server Database Utilities (Eseutil) is necessary. Note that the following example is truncated for
brevity:
C:\Program Files\Exchsrvr\MDBDATA>..\bin\eseutil /ms priv1.edb
Microsoft(R) Exchange Server Database Utilities
Version 6.5
Copyright (C) Microsoft Corporation. All Rights Reserved.
Initiating FILE DUMP mode...
Database: priv1.edb
****************************** SLV SPACE DUMP
*************************
Chunk
=====================================================================
==
512
110
1024
0 512
0 402
*************************
********************************
1536
512
2048
512
2560
512
3072
512
3584
512
4096
512
4608
118
0 394
************************
5120
0 512
********************************
5632
0 512
********************************
6144
0 512
********************************
6656
0 512
********************************
7168
0 512
********************************
7680
0 512
********************************
8192
238
0 274
*****************
=====================================================================
==
TOTALS:
Free:
3538
Reserved:
512
Deleted:
Committed:
4142
Unknown:
0
------------8192
*********************************************************************
**
******************************** SPACE DUMP
***************************
Name
Available
Type
ObjidFDP
PgnoFDP
PriExt
Owned
=====================================================================
==
priv1.edb
116
256-m
8960
33
32-m
32
65
32-m
80
75
301
8-s
77
302
1-s
MsgFolderIndexPtagDel Idx
0
80
305
1-s
MsgFolderIndexURLComp Idx
0
79
304
1-s
RuleMsgFolderIndex
0
78
303
1-s
61
236
2-m
7778
222
237
1-m
7691
63
257
8-s
MsgFolderIndex7 Idx
0
65
258
1-s
MsgFolderIndexPtagDel Idx
0
68
261
1-s
MsgFolderIndexURLComp Idx
0
67
260
1-s
RuleMsgFolderIndex
0
66
259
1-s
1-122
3
MsgFolderIndex7
0
Db
Tbl
Idx
Idx
1-23
16
Tbl
<Long Values>
8
LV
1-24
3
Tbl
Idx
1-33
1
Tbl
336
8821
8-m
14
<Long Values>
2
LV
342
8826
1-m
354
8827
1-s
338
8822
1-s
?T668f-T6654+Q3f88
0
MsgFolderIndex7
0
Idx
Idx
MsgFolderIndexPtagDel Idx
0
341
8825
1-s
MsgFolderIndexURLComp Idx
0
340
8824
1-s
RuleMsgFolderIndex
0
339
8823
1-s
97
9-m
100
105
243
1-s
*T668f+Q6749+S3001+Q6 Idx
0
60
232
1-s
?T668f+Q6749+S3001+Q6 Idx
0
59
109
1-m
17
108
1-m
FoldersIndex10
0
Idx
13
102
1-s
FoldersIndex13
0
Idx
14
103
1-s
FoldersIndex5
1
Idx
98
1-m
FoldersIndex6
0
Idx
10
99
1-s
FoldersIndex7
0
Idx
11
100
1-m
FoldersIndex8
0
Idx
12
101
1-s
15
104
1-m
ScopeFIDs DeleteTime
0
16
105
1-s
Folders
10
Tbl
<Long Values>
0
LV
Idx
Idx
Mailbox
2
Tbl
21
140
2-m
10
MailboxIndex2
0
Idx
22
141
1-s
MailboxIndex3
0
Idx
23
160
1-s
Msg
63
Tbl
<Long Values>
0
LV
19
112
2-m
194
106
359
1-m
14
---------------------------------------------------------------------253
The first section of output is the space dump of the .stm file. The output is directly from the contents of
the SLVAvail table in the .edb file. Each 2 MB-chunk, which is 512 pages, is listed to the left. The
columns represent the number of pages in each state in the .stm file. The last piece of information is a
graphical representation of the amount of space used in the individual 2 MB chunk.
****************************** SLV SPACE DUMP
******************************
Chunk
=====================================================================
==
512
1024
110
0 512
0 402
*************************
********************************
1536
512
2048
512
2560
512
3072
512
3584
512
4096
512
4608
118
0 394
************************
5120
0 512
********************************
5632
0 512
********************************
6144
0 512
********************************
6656
0 512
********************************
7168
0 512
********************************
7680
0 512
********************************
8192
238
0 274
*****************
=====================================================================
==
TOTALS:
Free:
3538
Reserved:
512
Deleted:
Committed:
4142
Unknown:
0
------------8192
Consider the following section of output. There are two columns, owned and available. The owned
value is the number of pages in the database that contains some data. The available value represents the
number of free pages available at the database root that can be distributed to tables as they need space
to grow.
******************************** SPACE DUMP
***************************
Name
Available
Type
ObjidFDP
PgnoFDP
PriExt
Owned
=====================================================================
==
priv1.edb
116
Db
256-m
8960
Consider the attachments table in the following section of output. There are two rows, one called 1-23,
which is the primary B+tree containing actual records, and then one called <Long Values>, which
contains binary blobs or fragments of records that are larger than 1 KB and cannot be stored in the
primary B+tree. The value under the owned column for 1-23 is 7778. This represents the total number
of pages owned by this table and all associated B+trees. This encompasses the primary B+tree, long
values trees, and any other secondary indexes that could be in use by this table. The next value is the
available pages, in this case 16, that can be reused by this individual table, but not by indexes or the
Long Value tree. Of the 7,778 pages in use by this table, the long value tree is occupying 7,691 and
there are 8 pages available:
******************************** SPACE DUMP
**************************
Name
Available
Type
ObjidFDP
PgnoFDP
PriExt
Owned
=====================================================================
==
1-23
16
Tbl
<Long Values>
LV
61
236
2-m
222
237
1-m
7778
7691
Consider a standard folder in use by someone in the database. The folder is 1-33. Note that internally,
Microsoft represents tables as numbers referred to as IDs. This would typically represent a user's Inbox
folder or other folder that the user created. In this case, there is a primary entry, 1-33, that is the table
itself. Listed under this row are associated Long Value and indexes to this table. There are also five
secondary indexes associated with this table.
Note:
Indexes come in two types, those created by schema and those created dynamically. In the following
output, for example, MsgFolderIndex7 would be considered a schema index. When the Microsoft
Exchange Information Store service creates this table, it also creates an index with this name.
Dynamically created indexes have an unusual, but logical naming convention. In the following
example ?T668f-T6654+Q3f88 is a dynamically created index with a key value being the aggregate of
the columns T668f, T6654, and Q3f88.
Overall, this table occupies 14 pages with 1 page available to the primary table. The Long Value owns
5 of the 14 pages owned total by this table, and has 2 free pages, while the table entry only has one. The
Owned value represents all pages in use by the table, indexes, and LV trees. The Available only
represents the number of pages available to that individual index/LV/Table and is not cumulative:
******************************** SPACE DUMP
***************************
Name
Available
Type
ObjidFDP
PgnoFDP
PriExt
Owned
=====================================================================
==
1-33
14
Tbl
336
8821
8-m
LV
342
8826
1-m
354
8827
1-s
338
8822
1-s
MsgFolderIndexPtagDel Idx
1
0
341
8825
1-s
MsgFolderIndexURLComp Idx
1
0
340
8824
1-s
RuleMsgFolderIndex
1
0
339
8823
1-s
<Long Values>
5
2
?T668f-T6654+Q3f88
1
0
MsgFolderIndex7
1
0
Idx
Idx
Idx
At the end of the dump is a line similar to the following. It contains a summation of the total number of
pages that are available throughout all the tables. By multiplying this value by 4,096, you determine the
true amount of white space in the database:
---------------------------------------------------------------------253
When studying a space dump to understand where space is being used in the database, first look to the
attachments table (1-23), messages table, and folders table, and determine how much space these three
tables occupy. If these tables combined do not represent the majority of the size of the database, the
space is being consumed by some other table or indexes. Examine the output for suspicious entries
occupying a large amount of space, or many small tables combined that consume a large amount of
space.
In this example, mailbox size matches the size of the database. The reason is that the tables that
actually store the data could occupy a larger amount of space depending upon the density of the pages
at the time, and if pages have been freed up to the database root. In most cases, this has proven to be
the situation.
Why Do Exchange System Manager and Outlook Show Different Sizes for the Same Mailbox?
When a calculation is performed for a size of a mailbox, consider the following:
Microsoft Outlook takes into account only what a user can see from the mailbox, so only
items that a user can see from the Outlook client in the mailbox folders are calculated.
Within a mailbox, many hidden items exist. Some of these items include third-party hidden
folders, rules, and items used to support the functionality included with an Exchange mailbox.
These hidden items are sometimes referred to as NON_IPM_DATA. Exchange System Manager
considers all related mailbox data, including NON_IPM_DATA when calculating the size of a
mailbox.
This implies that the size of the mailbox is usually bigger when viewing it from Exchange System
Manager, rather than viewing it from Outlook client.
There are also several bugs related to size calculations that may be a factor in understanding these
discrepancies. If you incur this problem and subsequently apply a fix to correct the problem, the size
counts may appear to be different until the Information Store Integrity Checker (Isinteg) is run to
correct the item count issues. In general, if you are attempting to understand an item count or size issue,
ensure you are running the latest version of the Microsoft Exchange Information Store service, and you
have run Isinteg after applying the fix. For information about fixes that can affect mailbox size
reporting, see the following Microsoft Knowledge Base articles:
SUMMARY
A hard repair occurs when you run an eseutil /p or edbutil /d /r command against an Exchange
Server database file, such as the Priv.edb, Pub.edb, or Dir.edb database. The repair goes through
the database and checks and repairs critical structures inside the database (such as system tables,
attachment tables, and so on) and checks for damaged pages in the databases.
If the repair encounters a page that is damaged (for example, an invalid checksum caused by a
modification to the page that was not preformed by Jet) it deletes the page (-1018). When this
happens, critical data may be lost after the repair finishes. This data may be part of an e-mail
message, a calendar appointment, a note, an attachment, or in the worst-case scenario, part of a
system table.
If that system table is the attachment table, every user on the server may lose the attachments to
their messages. This is only one possible scenario, but if there are damaged pages in the database,
data will be lost following a hard repair.
Important It is always best to restore from a backup whenever possible.
If you restore from a backup, you ensure that you have a good, clean, stable, database that will
start and run on your server. In almost every circumstance, it is faster and more reliable to restore
from a backup than to perform a hard repair on the database. This is because the repair runs at
approximately 4 to 6 gigabytes (GB) per hour, and you must run the Isinteg process after the
repair, which runs at approximately 3 to 6 GB per hour. (These rates are average; performance
may vary depending on how many passes the repair has to make on your database and the speed
of the hardware.)
For example, if you use the fastest possible hardware setup, a 50-GB database requires
approximately 8 hours for repair and approximately 8 hours for the Isinteg process, for a total of
16 hours. If you use a typical Wide SCSI-connected digital linear tape (DLT) 35/70, which
averages around 3 megabytes (MB) per second for restoration, the same database needs
approximately 5 hours for restoration. That is a time savings of 11 hours. Extremely high speed
"snapshot" type backup systems, such as the system from EMC Corporation, can restore a
database of this size in a matter of minutes.
If you have no backup, and no other option but to run a hard repair on your database, follow
these steps:
1. Run a hard repair on the database by using Eseutil /p or Eseutil /d /r.
2. Defragment the database by using Eseutil /d. Offline defragmentation creates a new
physical database structure and moves the existing data to that structure.
3. Check the consistency of the database by using Isinteg -fix. You may need to run Isinteg
several times until the summary report returns no errors.
For more information, click the following article number to view the article in the Microsoft
Knowledge Base:
192185 How to defragment with the Eseutil utility (Eseutil.exe)
182081 Description of the Isinteg utility
The Isinteg utility fixes the logical problems that may arise when you run a hard repair:
For the Exchange Server 4.0 and 5.0 private information store, run the following
command:
isinteg -fix -pri
For the Exchange Server 4.0 and 5.0 public information store, run the following
command:
isinteg -fix -pub
For the Exchange Server 5.5 private information store, run the following command:
isinteg -pri -fix -test alltests
For the Exchange Server 5.5 public information store, run the following command:
isinteg -pub -fix -test alltests
Note You cannot run the Isinteg -fix command against the Dir.edb database. Additionally, we
recommend that you do not run a hard repaired directory in a production environment.
For more information about Exchange disaster recovery, click the following article number to
view the article in the Microsoft Knowledge Base:
162353 Restoring an Exchange Directory
After you run the eseutil /p or edbutil /d /r command on the Priv.edb or Pub.edb databases, the
databases may exhibit the following symptoms:
After you run a hard repair on a database that has extensive damage, it is not fit for production
use until you have also performed the offline defrag followed by isinteg. Only run a hard repair
on your database as a last resort; if possible, always restore from a backup.
If Isinteg is run multiple times and does not correct the database corruption, you must use the
Exmerge utility to extract data from one database and place it in another database:
259688 How to use the Exmerge utility to extract data from a damaged private information store
MORE INFORMATION
To determine if a hard repair has been run against your database, dump the header by using the
following command line (the repair count will be zero if the databases have not been repaired):
eseutil /mh x:\exchsrvr\mdbdata\priv.edb |more
Applies to: Exchange Server 2007 SP3, Exchange Server 2007 SP2, Exchange Server 2007 SP1,
Exchange Server 2007
Topic Last Modified: 2009-03-16
You can use the Exchange Server Database Utilities (Eseutil.exe) /D switch to defragment and compact
a database offline. The defragmentation option makes used storage contiguous, eliminates unused
storage, and compacts the database, which reduces the database file size.
For instructions about how to use the Eseutil /D syntax, see How to Run Eseutil /D (Defragmentation).
During normal operations, database files never shrink below their current size. As space in the database
is freed by deletion of items, existing pages are reused where possible. Typically, a Microsoft Exchange
Server database will grow for several months after it is placed in service, but eventually the database
size stabilizes.
Under normal conditions, performing an offline defragmentation does not permanently recover
significant disk space. The file will tend to grow again to its previous size before defragmentation.
There is a significant amount of free space in the database that can be reclaimed and that will
not be reused.
There are ESE -1018 errors affecting the indexes of a database file. In such instances, offline
defragmentation rebuilds the indexes. Running an offline defragmentation effectively eliminates
this corruption.
A database file has been repaired using Eseutil /P. After running repair, Eseutil offline
defragmentation should be performed on the database file.
A mail storm occurs on a queue database file residing on an Exchange 2007 Hub Transport or
Edge Transport server. A mail storm is a large amount of mail that fills up the transport queue
faster than the transport service can process the e-mail messages. This behavior causes the
queue to fill with mail, and the Queue database expands when it needs to. When the mail from
the storm has been processed, and an online defragmentation has been run on the database,
some amount of free space remains in the database. To reclaim this free space and shrink the
database, run Eseutil /D to perform an offline database defragmentation.
When Not to Run Eseutil /D
There are situations where it is not appropriate to run Eseutil /D to defragment an Exchange database.
The following list describes some of those situations:
Eseutil offline defragmentation should not be run as any kind of standard maintenance.
Exchange runs an automatic online defragmentation nightly that handles the day-to-day
maintenance of Exchange. For day-to-day, month-to-month, or year-to-year maintenance, there
is no reason to run an offline defragmentation.
Eseutil defragmentation should not be run when the database is not in a consistent state.
Eseutil offline defragmentation should not be run when there is an available database to which
mailboxes could be moved. Doing so will cause less downtime for end users. Because offline
defragmentation is done offline, users will not have access to their mailboxes during
defragmentation. We recommend that to reduce the impact to the end user, you move the
mailboxes to a different database if available by performing a Move Mailbox operation. For
more information, see Moving Mailboxes.
Eseutil offline defragmentation should not be run when ESE -1018 errors affect the data portion
of a database file. In such cases, offline defragmentation will detect the error and not proceed.
For More Information
For more information about Eseutil, see the following topics:
To ensure that you are reading the most up-to-date information and to find additional Exchange Server
2007 documentation, visit the Exchange Server TechCenter.
Applies to: Exchange Server 2007 SP3, Exchange Server 2007 SP2, Exchange Server 2007 SP1,
Exchange Server 2007
Topic Last Modified: 2006-08-28
The Exchange Server Database Utilities (Eseutil.exe) repair mode corrects problems in the transport
server queue database, mailbox database, and public folder database at the page and Extensible Storage
Engine (ESE) table levels. However, Eseutil does not correct problems at the application level.
Therefore, after you repair a mailbox or public folder database using Eseutil, we recommend that you
run the Information Store Integrity Checker (Isinteg.exe) to repair the database at the application level.
Note:
Isinteg is not applicable to Exchange Hub or Edge Transport server queue databases. For more
information about transport server queue databases, see Working with the Queue Database on
Transport Servers.
During repair, it may be necessary to discard rows from tables or even entire tables. After completing
the ESE-level repairs, it is necessary to perform an application-level repair to correct problems that
may now exist at the application level because of missing data. You can use Isinteg to perform this
application-level analysis and repair on mailbox and public folder databases. The following example
illustrates how the repair mode in Eseutil works.
For example, a table in the database stores messages for all mailboxes. A separate table is used for each
user's Inbox folder. Suppose that a message is lost when using Eseutil to repair the message table.
Eseutil does not correlate the message with the reference to it in each Inbox folder because Eseutil
does not have the information about the cross-table schema of the application. Isinteg is needed to
compare the repaired message table with each Inbox to remove a lost message from the Inbox folder.
Eseutil looks at each Exchange database page and table and ensures consistency and integrity within
each table. Isinteg repairs a mailbox or public folder database at the application level and ensures the
integrity of the relationships between tables.
Repairing databases involves the following three stages, in this order:
1. Run Eseutil in /P mode to perform a database page-level and table-level repair.
2. Run Eseutil in /D mode to fully rebuild indexes and defragment the database.
3. Run Isinteg only on the mailbox or public folder database to repair the database at the
application level.
Note:
Always back up your mailbox, public folder, or transport server queue database before running
a repair against it, because the repair results in some data loss. For example, in some cases,
when the system metadata might get lost, the database is not able to be mounted.
Placing a Repaired Database Back Into Production
It is a judgment call whether to leave a repaired database permanently in production. The policy of
many administrators is to use repaired databases only for data salvage. Administrators move mailboxes
as soon as possible to another database, or merge the data from a repaired database into a known good
database.
Both Eseutil and Isinteg (used on mailbox or public folder databases) generate detailed repair log files
that list the errors found and corrected. For more information about causes and consequences of
specific errors, see Reference for Common Eseutil Errors.
Eseutil /P Best Practices
Use Eseutil /P when you cannot restore a database from backup, or when you cannot fully roll
transaction logs forward.
Note:
If you cannot roll transaction logs forward, consider a hybrid strategy. You can restore a working
version of the database from backup, repair the damaged database in the recovery storage group, and
merge the two databases.
We recommend that you follow these best practices when repairing a database:
Do not allow a repaired database to remain in production for an extended period of time.
Do not use the Eseutil repair option when you can restore from backups without any data loss.
You can run Eseutil repair mode on a mailbox or public folder database to correct an error
-1018. Eseutil discards the -1018 page and performs the repair. A Microsoft WebCast for
Microsoft Exchange Server 2003 discusses how to correct an error -1018. For more
information, see Microsoft Knowledge Base article 812531, Support WebCast: Microsoft
Exchange: Understanding and Resolving Error -1018.
Applies to: Exchange Server 2007 SP3, Exchange Server 2007 SP2, Exchange Server 2007 SP1,
Exchange Server 2007
Topic Last Modified: 2006-09-05
The Exchange Server Database Utilities (Eseutil.exe) restore mode can only be run on mailbox and
public folder databases restored from legacy streaming backups. This topic does not apply to transport
queue databases on the Edge and Hub Transport server roles because the queue databases are not
backed up. The Eseutil restore mode also allows you to view the Restore.env file. The Restore.env file
is created when restoring an online backup of the database, and it controls the hard recovery process.
Hard recovery is the process that changes a restored database back to its clean shutdown state by
playing transactions into the database from transaction log files. The hard recovery process controls
transaction log file replay into a database that has been restored using the legacy streaming backup
application programming interface (API). This process is different from a soft recovery that takes place
after restoring a database using the Volume Shadow Copy Service (VSS) backup API as well as after
recovering from a failure.
Backup applications that implement the Exchange legacy streaming backup API provide a setting in the
user interface to start hard recovery after the last backup set has been restored. In Microsoft Windows
NT NT Backup, this is called Last Backup Set.
If you fail to trigger hard recovery from the backup application, you must run hard recovery manually
from the command prompt with Eseutil before a restored database can be mounted. To initiate hard
recovery, you can select the Last Backup Set check box in the backup API when you restore your last
database, or you can use the Eseutil /CC command. In this command, the first /C indicates restore
mode and the second C is the mode modifier to start the hard recovery process. The hard recovery
process uses the Restore.env file that is generated during the restore process to determine how to
restore the database files and to determine what transaction log files must be replayed from the
temporary directory that the backup was restored to. After the databases are copied to their destination
location, and the transaction log files from the temporary directory are replayed into them, hard
recovery continues to replay any additional transaction log files that it finds in the transaction log file
path specified for the storage group of the restored database.
For instructions and syntax for running Eseutil /C, see How to Run Eseutil /C (Restore).
Controlling Transaction Log File Replay
Transaction log file replay behavior using Eseutil /CC depends on whether the database has been
victimized. If you are restoring to an alternative server, or you have deleted and re-created the original
database, only transaction logs in the temporary folder are replayed. Transaction logs in the normal
database folder are not replayed. This distinction avoids transaction log replay conflicts in cases where
Exchange Server knows that the database to which it is restoring is not the same as that from which it
was backed up. A database restored in this circumstance is called a victimized database.
Important:
After hard recovery succeeds, all files in the temporary folder (where Restore.env was created) are
deleted. Never place your only copy of a log file in the Restore.env temporary folder.
Note:
If you are unsure about the victimization status of a database, copy log files into both the temporary
and running folders. This will ensure that one log copy or the other will be considered for replay.
If a database has not been victimized, transaction logs will be replayed as follows:
The sequence of log files listed in the Restore.env file will be replayed first.
If additional log files exist in the Restore.env location, they will not be replayed under any
circumstances.
If additional matching log files exist in the running storage group log folder and they are in
contiguous sequence with the files listed in Restore.env, they will be replayed.
If additional log files exist in the running storage group log folder, and they do not match or are
not in contiguous sequence, and circular logging has been disabled, an error will occur and hard
recovery will fail. To resolve such errors, matching and contiguous log files must be located, or
you can use Eseutil /CC /T switches to ignore log files in the running folder and to replay only
log files listed in Restore.env.
If circular logging is currently enabled or was enabled at the time the backup was made, only
log files listed in Restore.env will be replayed.
If no log files exist in the running storage group log folder, recovery will complete successfully
using only the log files listed in Restore.env.
If a database has been victimized, transaction logs will be replayed as follows:
The sequence of log files listed in the Restore.env file will be replayed first.
If additional log files exist in the Restore.env location and they match and are contiguous with
the logs listed in Restore.env, they will also be replayed.
Additional log files in the running storage group log folder will not be replayed.
If a database has been restored to a recovery storage group, transaction logs will be replayed as follows:
Any other databases in the recovery storage group must be dismounted before beginning any
transaction log file replay.
The sequence of log files listed in the Restore.env file will be replayed first.
If additional matching log files exist in the running log folder for the recovery storage group and
they are in contiguous sequence with the files listed in Restore.env, they will be replayed.
If additional log files exist in the Restore.env location, they will not be replayed under any
circumstances.
Applies to: Exchange Server 2007 SP3, Exchange Server 2007 SP2, Exchange Server 2007 SP1,
Exchange Server 2007
Topic Last Modified: 2011-06-16
Recovery refers to the process of playing transaction log files into a database. There are two kinds of
recovery:
Hard recovery: A transaction log replay process that follows a database restoration from an
online backup
Soft recovery: A transaction log replay process that occurs after any of the following activities:
a database is remounted after an unexpected stop
transaction logs are replayed into an offline file copy backup of a database
logs are replayed into a Volume Shadow Copy Service (VSS) backup set
For more information about syntax and about running Eseutil /R recovery mode, see How to Run
Eseutil /R (Recovery).
Hard Recovery
Hard recovery occurs when transaction log files must be replayed into a restored online backup. In all
other recovery scenarios, soft recovery occurs. You can use Exchange Server Database Utilities
(Eseutil.exe) to perform a hard recovery by using by using the Restore mode (/C).
Soft Recovery
In the most common soft recovery scenario, an external event unexpectedly stops an Exchange
database, but the database and log files remain intact and in place. When the database is mounted again,
Exchange reads the checkpoint file and begins to replay the transaction log that is listed as the
checkpoint log. If no checkpoint file exists, replay begins at the oldest log file available in the
transaction log folder for the storage group.
Exchange writes completed transactions to the database files. These are transactions that are found in
the log file and that have not already been written. Exchange then reverses any incomplete transactions.
Exchange never begins writing a transaction into the database files until all the operations composing it
are secured to the log files. You do not have to physically undo or stop a transaction in the database if
all uncommitted transaction logs that exist when the unexpected stop occurs also exist when replay
begins.
Important:
A fundamental assumption of the soft recovery process is that no database or log files have been
moved, deleted, or destroyed either by the failure or by the administrator after the failure.
Specific Recovery Scenarios
The following sections describe various recovery scenarios.
Transaction log files are not in the current folder
Generally, you should always run Eseutil /R from the folder that contains the transaction log files to be
replayed. This is because the default soft recovery process looks in the transaction log files to find the
path to the databases. If you run Eseutil /R from a folder in which no log files exist, a new transaction
log file is generated, and this new log file will not contain the location of the databases. If you want to
run a soft recovery from outside the transaction logs folder, add the following switch to the command:
/Lpath_to_logfiles
The /I switch may not be necessary, depending on whether there are clean shutdown records in the
transaction logs for other databases that were attached to the logs. Using the switch in this circumstance
is recommended so that you do not have to start recovery again if there is a hanging attachment
somewhere in a log file.
If the /D switch does not exist, the database paths that are recorded in the transaction log files are used
to locate the databases. If the /D switch is used without a path, the current directory is used as the path
for the database files. If the /D switch is immediately followed (with no intervening space) by a file
path, that path is used to locate the database files.
To avoid typing errors, we strongly recommend that you eliminate the need for using paths that have
Eseutil switches whenever possible . To do this, run Eseutil from a folder in which all data files already
exist.
After recovery finishes and the database files are in clean shutdown state, the files may be moved into
the appropriate storage group and attached to the log files, thereby mounting the databases.
Note:
To make sure that a database mounts, you may have to click to select the This database can be
overwritten by a restore check box on the database object properties in the Exchange Management
Console.
Recovering a database that has missing log files
In Exchange Server 2007, a new feature named Lost Log Resilience (LLR) protects Exchange
databases from losing the last few log files, and enables faster recovery. When an LLR-protected log
file is missing or corrupted, typical database mounting or recovery by using Eseutil fails and does not
provide the new /A recovery option. Event ID 523 is logged to the Event log and states the kind of
failure that occurred. On a database on which an LLR-protected log file is missing or corrupted, you
can run Eseutil recovery by using the /A option in recovery mode as follows:
ESEUTIL /R Enn /A
By default, in a non-clustered Exchange Server 2007 server, only the last file is protected by LLR.
Therefore, this option can be used only when the last transaction log file is missing. For more
information, see Lost Log Resilience and Transaction Log Activity in Exchange 2007.
Note:
You can see the command-line reference and syntax for Eseutil by typing eseutil /? at a command
prompt. However, the /A option is not listed in the Exchange 2007 RTM version of the command-line
reference.
When you recovered a database that had missing log files in previous versions of Exchange, you would
have to either restore databases from backups or repair the existing database file by using Eseutil /P.
With Exchange 2007, database recovery is enhanced so that you can recover a database that has log
files missing in the LLR range by running the recovery command and using the /A option.
Applies to: Exchange Server 2007 SP3, Exchange Server 2007 SP2, Exchange Server 2007 SP1,
Exchange Server 2007
Topic Last Modified: 2006-08-18
Exchange Server Database Utilities (Eseutil.exe) integrity mode is a reliable way to verify whether an
Exchange Server database contains specific inconsistencies such as bad pages, inconsistent data,
flipped bits, missing data, or other issues that could appear in a database. Using this tool to test
database integrity is a safe approach because the check is performed in a read-only mode. It is
important to detect specific types of anomalies or inconsistencies to take proper steps to fix the
database. You should recover the database to a clean shutdown state before running an integrity check.
Many of the integrity checks involve reconstructing indexes and other data inside a temporary
database. Then, a comparison is done between the two databases. If you do not have free disk space
equivalent to 20 percent of the size of the files being checked, there is greater likelihood of running out
of disk space during the check. You can add the T switch to the Eseutil /G command to redirect the
scratchpad or temporary database to a drive with more space.
Note:
The Eseutil integrity mode does not perform a database recovery. If a database is inconsistent or is in a
dirty shutdown state, we recommend that you perform a recovery operation to make sure that the
database operations are completed correctly. After you perform the recovery operation, you can use the
Eseutil tool to perform the integrity check.
For more information about performing an integrity check using Eseutil, see How to Run Eseutil /G
(Integrity).
Applies to: Exchange Server 2007 SP3, Exchange Server 2007 SP2, Exchange Server 2007 SP1,
Exchange Server 2007
Topic Last Modified: 2006-08-18
Although the Exchange Server Database Utilities (Eseutil.exe) file dump mode is often overlooked by
administrators, it is a valuable troubleshooting and diagnostic tool. This mode does not repair or make
other changes to files. Its purpose is to provide you with information about the state of the database
files. For example, you can run the following file dump command to dump the header of an Exchange
mailbox database to determine if your database has been repaired using the Eseutil /P command:
ESEUTIL /mh C:\Program Files\Microsoft\Exchange Server\Mailbox\First Storage
Group\Mailbox Database.edb |more
If a repair has occurred, the output of the file dump has information similar to the following:
Repair Count: 2
Repair Date: 08/10/2006 09:19:57
In file dump mode, you can:
View header information for database, checkpoint, and transaction log files.
View header information for individual database pages.
Validate that a series of transaction log files forms a matched set, and that all files are
undamaged.
View space allocation inside the database.
View metadata for all tables or for a specific table in the database file.
For more information about syntax and about running Eseutil /M with different switches, see How to
Run Eseutil /M (File Dump).
The header for checkpoint, transaction log, and database files is the first physical page of each file.
Some files have a shadow header, which is a copy of the header on the second page of the file. The file
header contains important state and diagnostic information about the file. By correlating header
information from various files, you can determine whether the files belong together or are mismatched.
There are separate switches for viewing different kinds of file headers. Be sure that you use the correct
switch with the correct file type, or the output will be invalid.
Table 1 shows you switches that you can use to view headers of different types of database files.
To
View the header information of Exchange database files (.edb) for any ESE database
Eseutil /mh
including the Microsoft Exchange Server 2007 Hub Transport and Edge Transport server
switch
role Queue databases.
Eseutil /ml Validate the integrity and sequence of transaction log files for any Exchange 2007 ESE
switch
database.
Eseutil /mk
View the header information for Exchange database checkpoint files.
switch
Applies to: Exchange Server 2007 SP3, Exchange Server 2007 SP2, Exchange Server 2007 SP1,
Exchange Server 2007
Topic Last Modified: 2006-08-18
The Exchange Server Database Utilities (Eseutil.exe) tool in Microsoft Exchange Server 2007 includes
a /K switch that you can use to verify the page-level integrity of Exchange databases. The /K switch
can be used to detect file header damage. File header damage may occur in databases, log files, or
checkpoint files. In addition, you can use the Eseutil /K command to verify the checksum integrity of
the transaction log stream when all the databases in the storage group are dismounted.
For more information about procedures and syntax for running Eseutil in checksum mode, see How to
Run Eseutil /K (Checksum).
With the inclusion of Extensible Storage Engine (ESE) file features, Eseutil can checksum log files and
checkpoint files. Checksum mode doesn't allow you to checksum individual pages in the database.
However, you can use the page dump mode to determine whether the checksum on any given page is
correct.
Applies to: Exchange Server 2007 SP3, Exchange Server 2007 SP2, Exchange Server 2007 SP1,
Exchange Server 2007
Topic Last Modified: 2006-09-02
The Exchange Server Database Utilities (Eseutil.exe) /Y copy file mode is optimized to copy very large
files efficiently. You can use the /Y switch to copy a database file or log file. However, the mode is not
suitable as a general purpose copy utility.
Depending on disk and network conditions, copy file mode may be able to copy a file up to 20 percent
faster than a normal copy because the copy file mode in Eseutil copies files in larger blocks of data.
Note:
Because copy file mode does not accept wildcard characters (such as *.* to copy all files or *.edb to
copy all database files), you must fully specify a file name and copy one file at a time.
Applies to: Exchange Server 2007 SP3, Exchange Server 2007 SP2, Exchange Server 2007 SP1,
Exchange Server 2007
JET error
Error description
Error
-327
JET_errBadPageLink
(0xfffff
eb9)
Error
-501
JET_errLogFileCorrupt
(0xfffff
e0b)
Error
-510
JET_errLogWriteFail
(0xfffff
e02)
Error JET_errInvalidLogSequence
-515
(0xfffff
dfd)
Error
-530
JET_errBadLogSignature
(0xfffff
dee)
Error
-531
JET_errBadDbSignature
(0xfffff
ded)
Error
-532
JET_errBadCheckpointSignature
(0xfffff
dec)
Error
-533
JET_errCheckpointCorrupt
(0xfffff
deb)
Error JET_errRequiredLogFilesMissing
-543
(0xfffff
de1)
Note:
Deleting log files for a clean shutdown database
will affect the validity and roll forward
capabilities of previous backups.
If a database has not been shut down correctly, it is
still attached to one or more of the log files. These
log files are required to bring the database to a
consistent state. If these log files cannot be made
available, the database must be restored from
backup or repaired before it can be started again.
Error
JET_errDatabaseCorrupted
-1206
Error
-1216
JET_errAttachedDatabaseMismatch
(0xfffff
b40)
Error
-93958
6631
(Unkno Unknown Error
wn
Error)