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 […]
  • Move MySQL tmp directoryMove MySQL tmp directory You’ll eventually run into a client who has a crashed table in their database – this table will be pretty large – maybe even larger than the system’s default temporary directory (usually […]
  • Keep your WordPress site secure!Keep your WordPress site secure! I work for a hosting company. On average, I’ll clean up at least 3-4 WordPress sites each month for our clients. Most of the time, they’re running on old versions of WordPress and have […]
  • Download CentOS 7 Nightly BuildsDownload CentOS 7 Nightly Builds As the CentOS folks are working on releasing a final version of CentOS 7, you can get in on the action and download their nightly builds. We’re estimating (guessing? Based on previous […]
  • Reduce TIME_WAIT socket connectionsReduce TIME_WAIT socket connections Some time in your life you’ll run across an Apache server that always has tons of TIME_WAIT connections just seeming to hang out. While these don’t take up as many resources as an […]

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

  1. thanks for you tutorial!

Leave a Reply to Michel Cancel 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=""> 

*