Email migration using imapsync
Email migration is tough job. There are application that can do this but, it will not include emails with attachments.
I found imapsync do the job for me. How I did it? Here’s how:
Install imapsync
# apt-get install imapsync
The syntax is:
# /usr/bin/imapsync \
—host1 imap.truc.org —user1 foo —passfile1 /etc/secret1 \
—host2 imap.trac.org —user2 bar —passfile2 /etc/secret2
This syntax will only migrate 1 email account from 1 domain to another. I created a script that will read the details from file and process the migration.
#!/bin/sh
while read v1 v3 v4 v5 v6
do echo”$v1″ > gmail.account
echo “$v2″ > gmail.passwd
echo “$v4″ > domain.account
echo “$v5″ > domain.passwd
echo “$v6″ > domain.log.account# to test the script you have to add —dry
# Dry run
imapsync —host1 imap.gmail.com —ssl1 –authmech1 LOGIN —user1 $v1 —password1 $v2 —host2 mail.domain.com —ssl2 —authmech2 LOGIN —user2 $v4 —passfile2 $5 —skipsize —allowsizemismatch —dry > /home/root/imapsync/logs/$v6
done < migrate.account
This script will read the email account detail from migrate.account up to the last record. Lists of email accounts that you want to migrate.
email@gmail.com gmailpassword email@domain.com domainpassword email_log
To run the script:
You have to set the permission of the script
# chmod 744 email.migration
Create a log folder
# mkdir logs
Run the script
# ./email.migration
And of you go. Now, monitor the migration in log folder
Very straight-forward guide. Great idea to use shell-variables to use enter username and password. The only problem is that you are limited to your local bandwidth (assuming you’re not running it on a server in a data center).
Next time, you might also want to look into Yippiemove (http://www.yippiemove.com). It’s not free, but it’s dead simple to use and is not limited to your local bandwidth.
In this time of crisis every dime is important. Besides, I run it in the data center that’s why our migration only took some time to complete.