migrating from Exchange 2007 to Google Apps Mail

Recently I’ve moved some mailboxes from Microsoft’s Exchange 2007 to Google Apps for your Domain (GAFYD). Here is how, let’s start Homer alike from the end before getting to the beginning…
If you only have a single account with few emails, you could simply try to drag`n´drop your emails and folders in Thunderbird or Outlook. The first has the habit to create folders without being asked for, the latter does crash even with few emails on several systems. On others it runs rock-solid – a mystery.
Therefore I’ve sticked to imapsync, which is among fetchmail and BASH scripting to be known by every single mailsystem admin! My Exchange server as well as Google accounts are run in German; so don’t forget to adjust folder names (“Gesendete Elemente” is “Sent Items” etc.):
#!/bin/bash
# Exchange to Google Mail migration script by W-Mark Kubacki
# exchange_to_gmail.sh
ISCMD="--dry --justfolders
--host1 chlorium.ossdl.de --port1 993 --user1 $1 --password1 $2 --ssl1 --authmech1 LOGIN \
--host2 imap.googlemail.com --port2 993 --user2 $3 --password $4 --ssl2 --authmech2 LOGIN \
--syncinternaldates --split1 100 --split2 100 --useheader Message-ID --skipsize --skipheader X\-MS\-Exchange\-Organization\-.* \
"
#prefixed folders, (Exchange_Name Regextrans2_to_Google)
PFOLD=("Gesendete Elemente" "s/Gesendete Elemente/Gesendet/"
"Gel&APY-schte Elemente" "s/Gel\&APY\-schte\ Elemente/Papierkorb/"
"Entw&APw-rfe" "s/Entw\&APw\-rfe/Entw&APw-rfe/")
#...and their excludes
PEXCL="^(?:Gesendete|Gel\&APY\-schte|Entw\&APw\-rfe)"
# these do not belong to INBOX, too
OEXCL="^(?:Aufgaben|Journal|Junk\-E\-Mail|Kalender|Kontakte|Notizen|Postausgang|RSS\-Feeds|Synchronisierungsprobleme|Trash)"
######################################################
echo "-- STARTING --"
#synchronize INBOX only
while ! imapsync ${ISCMD} --exclude ${OEXCL} --exclude ${PEXCL}; do
echo "[INBOX]: IMAPSYNC is not done yet, re-trying after 2 minutes..."
sleep 120
done
# then, sync "sent items", "drafts" and such, with prefix [Gmail]
CNT=0
while [ $CNT -lt ${#PFOLD[@]} ]; do
PA="${PFOLD[CNT]}"
PB="${PFOLD[CNT+1]}"
let CNT=CNT+2
while ! imapsync ${ISCMD} --prefix2 '[Gmail]/' --folderrec "${PA}" --regextrans2 "${PB}"; do
echo "[${PA}]: IMAPSYNC is not done yet, re-trying after 2 minutes..."
sleep 120
done
done
echo "-- DONE --"
Fortunately I was allowed to reset passwords, therefore this script was run for every account by:
(I’ve been the only user on the box which made passing passwords as parameters acceptable)
{ while IFS=';' read u1 p1 u2 p2; do
./exchange_to_gmail.sh "$u1" "$p1" "$u2" "$p2"
done ; } < accounts.csv
and (see imapsync’s readme):
user0001;password0001;user0002;password0002 user0011;password0011;user0012;password0012
Google seems to have duplicate suppression enabled even for IMAP uploads – don’t let guide you by the message count. Imapsync has verifycation built-in.
Calendar and contacts have been migrated by another tool, hence after a night of sleepyfull waiting everything was back online again.
See also: http://www.thamtech.com/blog/2008/03/29/gmail-to-google-apps-email-migration/















Follow me on Twitter
How you migrated shared folders from MS Exchange/Outlook to Google ?
Luke, by
It was a lot of manual work, but finally I came up with scripts even for this.
Hi, can you make a link to your bash script, because on WP it seems to be fucked up…
thanks in advance.
Guillaume, just click on the “view source” button (that leftmost with the brackets) and the source code should show up unformatted in a popup.