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 […]
  • Install CSF/LFD Firewall on your Linux Server The first thing on your mind when setting up a new Linux server (dedicated or VPS) is how you can increase security.  One of the best tools in your bag of tricks should be the CSF […]
  • 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 […]
  • Learn the CSF command line options You have CSF installed and use the GUI to do most things.  (If you don’t have it installed yet, you can read our article on how to install csf).  BUT – knowing the csf (ConfigServer […]
  • Delete files that are x days oldDelete files that are x days old Sometimes in Linux, you want to clear out older files in a directory. One instance would be if you have a security system and it continuously writes video files to a directory on your NAS […]

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

  1. thanks for you tutorial!

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

*