Overview
Sometimes when moving or deleting a large number of items in a batch from Apple Mail in macOS, the items start duplicating out of control, resulting in huge sizes of accounts, hindering server performance.
As a side-effect, the mailbox may reach the email quota in a short amount of time. Since re-indexing the account and restarting the server will not resolve the issue, follow the steps below to fix this issue.
Diagnosis
If we delete an email completely in Apple Mail (delete from Inbox + delete from Trash) when the email client is in offline mode, we will make them out of sync to the server and have still this email(s) on the server. And after this deletion, if we also delete this email(s) on webmail, they will be transferred to Trash in webmail and be synched in email clients as well. So we will have these emails in the client's trashes too. It is causing the discrepancy between the Apple Mail client and the Kerio Connect server. Such inconsistency may lead to duplicated items appearing on the server-side.
It is considered as the Product Bug coming from the Apple Mail side, as this behavior was tested with the Postfix server and Thunderbird email client, completely excluding Kerio Connect from the equation.
Solution
-
Navigate to the Kerio mail store folder. The default locations are:
-
Windows:
C:\Program Files\Kerio\MailServer\store\mail
. -
macOS:
/usr/local/kerio/mailserver/store/mail
. -
Linux:
/opt/kerio/mailserver/store/mail
.
-
-
Navigate to the affected user folder.
-
Delete
.journal.db
,specguid.fld
, and the__keriomapi_STORE
folder.Note: deleting .journal.db and specguid.fld stops the duplication issue.
-
Navigate to the affected folder.
-
If the folder in question is
Deleted items
, delete all files in the folder, exceptindex.fld
,search.fld
andstatus.fld
, and then clear the#msgs
folder. -
Use 3rd party tools like dupeGuru (GUI) or fdupes (terminal-based), find and delete duplicate emails.
Note: Please make sure you have a backup from the user's mail folder if possible to avoid any data loss as the above tools are 3rd party which we cannot guarantee their functionality.
-
Navigate to webadmin GUI > Users and reindex the mailbox of the affected user.
Mac/Linux script
For the above procedure, we have developed a script to automatically perform the needed operations.
It should be made executable (chmod +x find_remove_duplicates.sh
) and based on the OS, certain lines about starting/stopping the Kerio Connect service should be uncommented.
RAID recommendations for Mac
If you're using SoftRAID (configured as a 2 drive mirror) on the boot partition of the Kerio server, please consider the following procedure:
- Stop the Kerio Connect server.
- Remove the current mirror. This is the boot volume, as well as where the message store resides. The message store is in a custom location on the RAID, as opposed to the default
/usr/local/kerio/mailserver/
- Attach a new hardware RAID, and copy the message store directory to the new RAID.
- Start the Kerio Connect server and configure Kerio Connect to use the new location for the store directory. For more information, please refer to Editing Kerio Connect Configurations to Use the Correct System Paths.