Migrate your IMAP data

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 ptijo --password1 MASKED --sep1 / --prefix1 "" 
--host2 www.tumfatig.net --ssl2 --user2 ptijo --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 ptijo --password1 MASKED --sep1 / --prefix1 "" 
--host2 www.tumfatig.net --ssl2 --user2 ptijo --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 ptijo 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 ptijo --password1 MASKED --sep1 / --prefix1 "" 
--host2 www.tumfatig.net --ssl2 --user2 ptijo --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

Move the e-mail

Copy a quite safe but since I have no fear and no will to keep the old IMAP server up, I might move the e-mail rather than just copy them:


Sources:

That’s All Folks!

2 Comments

  • Gene Leung Sun, 01 Jul 2012 17:00:24 +0000 Reply

    May I ask a dumb question? Why you move away from the zarafa and toward Sogo?

    • Joel Carnat Mon, 09 Jul 2012 12:57:21 +0000 Reply Author

      It was because I wanted to access the Calendar and Address-book from my MacBook with native tools. And, at the time of writing, there was only a plugin for Outlook.

Leave a Reply

%d bloggers like this: