Sunday, 14 October 2012

Migrating email to Gmail / Google Apps for business

Migrating email IMAP to IMAP

We have a customer very unhappy with his current service provider. He has recently moved mail from POP to IMAP and wanted to move elsewhere for mail. I told him of the positive experience I've had with Google Apps. He is a power user and has 20GB of mail to move. My job was to move the mail from one mail provider to another over a weekend.

Outlook doesn't cut it (see posts passim) and silently drops mail even though it reaches 100% completion with no errors. I could have used Google's plugin for Outlook, but this would have taken forever. I only had a weekend as the customer wanted to be fully migrated by Monday so he could tell his existing provider where they could put their customer service.

I had a look around and discovered offlineimap. It can do IMAP to local disk, local disk to IMAP, IMAP to IMAP and even has a Gmail option.

Sadly, I discovered that the Gmail option is a read-only affair. You cannot use offlineimap to backup to import into a Gmail account. However, you can tell offlineimap to write to an IMAP account. I therefore chose to run it in IMAP<->IMAP mode. This is how I migrated my customer:
#apt-get install offlineimap
Edit ~/.offlineimaprc
[general]
accounts = MigrateBobbinsToGmail
socktimeout = 600
# Gmail max attachment size
maxsize = 25000000


[Account MigrateBobbinsToGmail]
localrepository = Gmail
remoterepository = Bobbins

[Repository Gmail]
type = IMAP
remotehost = imap.gmail.com
remoteport = 993
remoteuser = example@gmail.com
remotepass = password
ssl = yes

[Repository Bobbins]
type = IMAP
# We don't want any mail/folder structure to be copied back to here.
readonly = True
remotehost = imap.bobbinsprovider.foo
remoteuser = example@bobbinsprovider.foo
remotepass = password

Save the file. Make sure the number to trim any emails which are >25MB big on the bobbinsprovider.foo server and then run. If you have big attachments, you are going to end up with errors importing into Gmail and offlineimap will stop.

$ offlineimap -u blinkenlights

 This is just one example of how offlineimap can be used, but it is a very flexible swiss-army IMAP tool.

No comments: