I just needed to migrate all mails from a Google mail account to a Dovecot IMAP server. I did this with a tool called “Imapsync“.

I just wanted to synchronize all mails from the Google sent mail folder to the “Sent” folder of Dovecot and all mails from the Google “All Mails” view to a folder called “Archive” of the Dovecot account.

You need to make sure that you synchronize the “Sent” mails first as these are also included in the “All Mails” view and otherwise will not be added to the “Sent ” folder in addition.

This is the command I used for the migration:

With the “–exclude” option you can specify which folders should not me synchronized. I excluded the Inbox as I just wanted to sync all mails to the “Archive” folder of my Dovecot account.

The “–folderlast” option makes sure that the “All Mails” folder of Google will be synchronized at the end, after all other folders have been synchronized.

With the “–regextrans2” options you can specify which source folder name should be synchronized to what target folder name. You need to adapt that in order to match your environment!

This is a real sync so you can have already mails in your target Dovecot account before which will not be deleted. And you can run this command several times and it will just only synchronize the mails which have changed on the Google mail account in the meantime.

Migrate IMAP account from Google Mail to Dovecot IMAP
Tagged on:             

One thought on “Migrate IMAP account from Google Mail to Dovecot IMAP

  • 21.01.2022 at 23:26

    Thanks! I initially got pretty overwhelmed with all the options imapsync has and this helped out tremendously.


Leave a Reply

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