imapsync script to migrate Gmail to Google Apps


/ Published in: Bash
Save to your folder(s)

Based on the good initial coverage [over here](http://www.thamtech.com/blog/2008/03/29/gmail-to-google-apps-email-migration/).


Copy this code and paste it in your HTML
  1. #!/bin/bash LOGFILE=imapsync.log FOLDERS=( 'Folder1' 'Folder2' 'Folder3' 'Folder4' '...' 'FolderN' 'INBOX' 'All Mail' 'Bin' 'Drafts' 'Starred' 'Sent Mail' ) TIMES=( '--minage 1090' '--maxage 1091 --minage 999' '--maxage 1000 --minage 908' '--maxage 909 --minage 817' '--maxage 818 --minage 726' '--maxage 727 --minage 635' '--maxage 636 --minage 544' '--maxage 545 --minage 453' '--maxage 454 --minage 362' '--maxage 363 --minage 271' '--maxage 272 --minage 180' '--maxage 181 --minage 89' '--maxage 90' ) echo "Starting" > $LOGFILE for FOLDER in "$@" do for ((j=0;j<${#TIMES};j++)) do TIME=${TIMES[${j}]} echo "" >> $LOGFILE echo "*** $FOLDER $TIME ***" >> $LOGFILE echo "" >> $LOGFILE while ! ~/imapsync-1.267/imapsync --host1 imap.gmail.com \ --port1 993 --user1 [email protected] \ --passfile1 ./passfile --ssl1 \ --host2 imap.gmail.com \ --port2 993 --user2 [email protected] \ --passfile2 ./passfile --ssl2 \ --syncinternaldates --split1 100 --split2 100 \ --authmech1 LOGIN --authmech2 LOGIN \ --include "$FOLDER" \ $TIME \ --useheader "Message-ID" \ --useheader "Date" --skipsize \ --regexmess 's/Delivered-To: user\@gmail.com/Delivered-To: user\@domain.com/gi' \ --regexmess 's/<user\@gmail.com>/<user\@domain.com>/gi' \ --regexmess 's/^((To|From|Cc|Bcc):.*)user\@gmail.com(.*)$/$1user\@domain.com$3/gim' \ --regexmess 's/Subject:(\s*)\n/Subject: (no--subject)$1\n/ig' \ --regexmess 's/Subject: ([Rr][Ee]):(\s*)\n/Subject: $1: (no--subject)$2\n/gi' >> $LOGFILE 2>&1; do echo "" >> $LOGFILE echo "***** NOT COMPLETE - $FOLDER $TIME *****" >> $LOGFILE echo "" >> $LOGFILE tail -100 $LOGFILE | mail -s "Imapsync Restarting for $FOLDER $TIME" "[email protected]" echo -n "Sleeping..." >> $LOGFILE sleep 1m echo "Done." >> $LOGFILE done echo "" >> $LOGFILE echo "***** COMPLETE - $FOLDER $TIME*****" >> $LOGFILE echo "" >> $LOGFILE tail -100 $LOGFILE | mail -s "Imapsync Complete for $FOLDER $TIME" "[email protected]" done done echo "**** DONE ****" >> $LOGFILE tail -100 $LOGFILE | mail -s "Imapsync Complete" -c "[email protected]"

URL: http://www.base6.com/2009/06/15/migrating-from-gmail-to-google-apps/

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.