Migrate your IMAP data

       459 words, 3 minutes

On my way to move from Zarafa to SOGo, I needed a way to migrate my e-mail between the two systems. Both provides IMAP capabilites and that’s the service I’m gonna use to move the data.

You can either copy/move the e-mail manually using your favorite IMAP client or automate the migration using imapsync.

Here are simple examples to show you how it works.

Test drive

You can simulate the command w/o any damage ; just use the --dry parameter:

# imapsync --host1 zarafa.tumfatig.net --ssl1 --user1 joe --password1 MASKED  \
           --sep1 / --prefix1 "" --host2 www.tumfatig.net --ssl2 --user2 joe  \
           --password2 MASKED --folder INBOX --noauthmd5 --idatefromheader    \
           --skipsize --allowsizemismatch --dry
(...)
Time: 25 s
++++ End looping on each folder ++++
++++ Statistics ++++
Time                   : 28 sec
Messages transferred   : 0 (could be 147 without dry mode)
Messages skipped       : 0
Total bytes transferred: 0
Total bytes skipped    : 0
Total bytes error      : 0
Detected 0 errors

Copy the INBOX folder

Remove the --dry option to really copy the e-mails. This will take a bit more time:

# imapsync --host1 zarafa.tumfatig.net --ssl1 --user1 joe --password1 MASKED  \
           --sep1 / --prefix1 "" --host2 www.tumfatig.net --ssl2 --user2 joe  \
           --password2 MASKED --folder INBOX --noauthmd5 --idatefromheader    \
           --skipsize --allowsizemismatch
(...)
Time: 129 s
++++ End looping on each folder ++++
++++ Statistics ++++
Time                   : 132 sec
Messages transferred   : 147
Messages skipped       : 0
Total bytes transferred: 25622686
Total bytes skipped    : 0
Total bytes error      : 0
Detected 0 errors

Copy a whole sub-folder

You may want to copy a single whole sub-folder. This would require the --folderrec parameter.

First of all, get the exact name of the folder using raw IMAP commands:

# openssl s_client -connect zarafa.tumfatig.net:imaps
(...)
* OK Zarafa IMAP gateway ready
. login joe MASKED
. OK LOGIN completed
. list "" "*"
* LIST (HasNoChildren) "/" "INBOX"
(...)
* LIST (HasNoChildren) "/" "Archives/Free"
* LIST (HasNoChildren) "/" "Archives/Jobs/NetXP"
* LIST (HasNoChildren) "/" "Archives/Jobs/Altran"
* LIST (HasNoChildren) "/" "Archives/Jobs/Dell"
* LIST (HasChildren) "/" "Archives/Jobs"
* LIST (HasChildren) "/" "Archives"
* LIST (HasNoChildren) "/" "Trash"
. OK LIST completed
. logout
* BYE Zarafa server logging out
. OK LOGOUT completed
closed

Now that you know the exact name of the folder you want to copy, just do it (c):

# imapsync --host1 zarafa.tumfatig.net --ssl1 --user1 joe --password1 MASKED  \
           --sep1 / --prefix1 "" --host2 www.tumfatig.net --ssl2 --user2 joe  \
           --password2 MASKED --folderrec "Archives/Jobs" --noauthmd5         \
           --idatefromheader --skipsize --allowsizemismatch
(...)
Time: 29 s
++++ End looping on each folder ++++
++++ Statistics ++++
Time                   : 88 sec
Messages transferred   : 240
Messages skipped       : 10
Total bytes transferred: 12719525
Total bytes skipped    : 134980
Total bytes error      : 0
Detected 0 errors

That’s All Folks!