Incremental E-Mail backup and migration using mnIMAPSync 2

Yet another IMAP syncing tool

Two years ago when I first released mnIMAPSync, there were several mail syncing tools available. The problem with most of them was that when performing incremental E-Mail backups or migrations, some of the e-mails, mostly the ones that didn’t conform the RFC, were being duplicated in the mirror server. This was due to invalid headers and invalid or non-existent message-id.

With no tool available in hand, I had to code one myself that did the job correctly. The main differences with mnIMAPSync and the other tools available is that mnIMAPSync checks several headers for each message and creates a rapid access index so that when the mirror server gets crawled, existing messages won’t get duplicated.



This tool is coded in java, so you will need a valid JRE. If you don’t have Java installed on your system, visit and download the newest release.

Java Download Page

Follow the site instructions to download and install the Jave Runtime Environment.


Next you have to download mnIMAPSync. You can either download the latest release, or the latest source code from Github and compile your jar. To download a precompiled release visit and download the latest.

mnIMAPSync Download

Once downloaded the Zip distribution, extract the package contents to a directory using your favorite tool.

Running the program

This is a command line application, so you will need a terminal/cmd window.

In windows you can use cmd.exe (Start->Run->cmd.exe)

To use the program you simply have to specify the required command line arguments. You can find a list of these arguments in the program homepage.

For this tutorial we are going to migrate a GMail account to a regular mail account in a personal server. If you execute the process in a regular basis, each migration will run incrementally and the process will only copy messages and folders that don’t exist in the target server.

The above command will sync a source account in gmail to a backup account
host1, port1, user1, password1 and ssl1 are the parameters that specify the source server connection and authorization options. In this case we will connect to gmail’s imap server using ssl.
host2, port2, user2 and password2 are the parameters that specify the target server connection and authorization options. In this case we are connecting to using a regular connection (not ssl encrypted).
threads parameter indicates the number of threads to use. In this case there will be 3 thread workers, so the program will make 3 connections to the source and target server to run the tasks in parallel.
delete is an optional parameter that indicates if we want to delete folders and messages in the target server that no longer exist in the source server.

Leave a comment

Your email address will not be published. Required fields are marked *

2 thoughts on “Incremental E-Mail backup and migration using mnIMAPSync