Have you been in the situation where you needed to move everyone’s mail from one provider to another? It’s a pain to do using the mail client one at a time, but with this guide, you’ll be able to create a csv with everyone’s info and run one command to fire it all off. All you need is a Linux machine to do it.
First, you’ll need to install the epel repo (skip if you already have it):
CentOS 5 (as root):
CentOS 6 (as root):
Now, use yum to install imapsync. It will automagically install all of the deps.
Now that it’s installed, let’s print out the help file and take a look at all of the usefulness of imapsync:
host1 - source host2 destination
/bin/imapsync --host1 192.168.0.2 --user1 This email address is being protected from spambots. You need JavaScript enabled to view it. --password1 1raja23 --host2 192.168.0.3 --user2 This email address is being protected from spambots. You need JavaScript enabled to view it. --password2 1raja23
Script for migration all mail from host1 to host2 with imap bulky.
# cat /scripts/imapsync.sh
##############start#######
#!/bin/bash
logfile="sinklog.txt"
host1=192.168.0.2 # host1 is Source
host2=192.168.0.3 # host2 is Dest
domain=test.com # domain is where email account is
# everything after @ symbol
###### Do not modify past here ######
date=`date +%X_-_%x`
echo "" >> $logfile
echo "------------------------------------" >> $logfile
echo "IMAPSync started.. $date" >> $logfile
echo "" >> $logfile
{ while IFS=';' read u1 p1; do
user=$u1"@"$domain
echo "Syncing User $user"
date=`date +%X_-_%x`
echo "Start Syncing User $u1"
echo "Starting $u1 $date" >> $logfile
#echo "imapsync --nosyncacls --syncinternaldates --host1 $host1 --user1 $user --password1 \
#$p1 --host2 $host2 --user2 $user --password2 $p1"
imapsync --nosyncacls --syncinternaldates --host1 $host1 --user1 $user --password1 $p1 --host2 $host2 --user2 $user --password2 $p1
date=`date +%X_-_%x`
echo "User $user done"
echo "Finished $user $date" >> $logfile
echo "" >> $logfile
done ; } < userlist.txt
date=`date +%X_-_%x`
echo "" >> $logfile
echo "IMAPSync Finished.. $date" >> $logfile
echo "------------------------------------" >> $logfile
####end#####
2. userlist.txt file should be like with with username and password
cat /home/satya/migration_list_test.csv |awk -F',' '{print $1";"$3}'
user;password
user2;password2