Migrate mail from one server to another with imapsync

Rob —  October 11, 2013 — 2 Comments

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:

Now let’s get to business and start a sync. Let’s just do one user first before we jump into doing multiple at once.

Our info for this task:
Old: server=old.mailserver.com, user=test@domain.com, pass=mypasswd
New: server=new.mailserver.com, user=test@domain.com, pass=mypasswd

Here’s the command:

Let’s migrate multiple people at once now!

Create a file full of info called ‘file.txt’. An example is here

Now, paste this into sync_loop_unix.sh

(Make sure to change the hosts in the sync_loop_unix.sh file)

Make it executable:

Now run it!

You can add as many accounts as you want in the csv file.

Read more about imapsync on their official page: http://imapsync.lamiral.info/

Related posts from Linux Brigade!

  • Migrating from Plesk to cPanel via commandlineMigrating from Plesk to cPanel via commandline If you’re anything like me, you prefer to do things via command line (CLI) rather than relying on a GUI to do most things in Linux. You also realize that while some of us don’t like to use […]
  • Try a DigitalOcean VPS free for a month (or two)Try a DigitalOcean VPS free for a month (or two) Have you been meaning to try out an SSD Linux server on Digital Ocean but keep putting it off? LinuxBrigade.com is currently being hosted on a DigitalOcean server and now you can get a […]
  • Add time and date to your bash historyAdd time and date to your bash history Often, you’ll go looking for a shell command that you used in the past – you can remember around when you did it but of course that won’t help you because by default the bash history won’t […]
  • Run fsck on a XenServer Virtual MachineRun fsck on a XenServer Virtual Machine You hope that you won’t ever need to, but you may one day need to run fsck on a Linux XenServer VM that won’t boot.. no worries, attach the storage from that VM on another VM and run it […]
  • Delete cPanel account error_log filesDelete cPanel account error_log files If you have a large number of accounts on your server, you may also be wasting a lot of space with the error_log files in each account. Some can get very large – and while you want to […]

2 responses to Migrate mail from one server to another with imapsync

  1. thanks for you tutorial!

Leave a Reply

Text formatting is available via select HTML.

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url=""> 

*