An update:

I was able to migrate using 3rd option (Google Takeout + mb2md). After running mb2md I converted from Maildir++ (dotted) folders to hierarchical folders by hand, moved everything from under Inbox/cur to cur, and removed Inbox folder. Then simply copied the converted folders to mail_location and restarted Dovecot. Dovecot seemed to re-index everything and I was able to access my converted account from Evolution. Things would be simpler if I didn't use hierarchical folders (LAYOUT=fs).

One thing I noticed there is some duplication of messages in Inbox and Archived folders. Another thing is I'm not sure if I can merge Inbox and Archvied folders into a single Inbox folder (I can try). And I'd still would very much like to use Option #1 (doveadm backup directly from gmail), so if anyone has any success with this option please share your experience.

Thank you,
Yuri

On Sun, 2019-08-11 at 15:05 -0700, Yuri via dovecot wrote:
Hi everyone,

I'm trying to migrate my gmail to dovecot following instructions at https://wiki.dovecot.org/Migration/Gmail

Using -a 'virtual/All' option does not seem to work because the gmail folder with that name does not exist, but -a '[Gmail]/All Mail' seem to work. I'm using the following command:

sudo doveadm \
-o imapc_host=imap.gmail.com \
-o imapc_user=user@gmail.com \
-o imapc_password=gmailpassword \
-o imapc_features="rfc822.size gmail-migration" \
-o imapc_port=993 \
-o imapc_ssl=imaps \
-o ssl_client_ca_dir=/etc/ssl/certs \
-o imapc_ssl_verify=yes \
backup -a '[Gmail]/All Mail' -O '-$GmailHaveLabels' -R -u user@exmaple.com imapc:

The problem is this command only migrates approximately 25% of my emails by size. Google Takeout exports 4 times more data in mbox format, the size of exported mboxes aligns with what Google tells me a the bottom of gmail settings page.

I experimented with other options of 'doveadm backup' command, but they all resulted in less data being migrated. The above options are the best I was able to achive so far.

Another option I was considering is to convert Google Takeout mboxes to dovecot format. I tried using 'doveadm import' command, but got confused with various user and search query options of the command. The best I was able to achive was to output a folder under /Takeout which mimics my mbox structure, but with no imported messages.

A third option I'm considering is to convert Google Takeout mboxes using mb2md command. Conversion seems to work fine, but the output is in the traditional (dotted) format, and for historical reasons I use 'LAYOUT=fs' option. So I need to do some extra work to convert folder names. And even if I do so, I'm still not sure if I can import Maildir to dovecot because dovecot's Maildir has other information, such as indices, logs, etc., not just email folders.

I'll keep investigating the second and the third option because it seems that Google Takeout gives me all my emails, but I'm not sure if those are the right paths.

I wanted to ask the experts about the best option to migrate gmail to dovecot. Has anyone being able to successfully migrate all their emails from gmail and what steps have been used for that?

My Dovecot version: 2.3.4.1

Thank you,
Yuri