How to migrate mails from cpanel to cpanel on different servers ?

YoYoC

New member
Hi,
I have the same email account on different cpanel servers.
When I copy content of mail/domain.com to A new server, it works well.
But since I have mails in both servers, I get "file already exist" notification. I tried to "skipping" existing files, but this time the migration failed. I was afraid to overwrite existing files, thinking I may lose mails in the destination server.
So what should I resolve this problem?
All advice would be appreciated.
 
You are correct in your assumption. In theory, if you merge the files skipping the ones that are duplicate you have done the right thing.

Just ensure that the permissions on the files are correct when you have finished. As if the accounts have the same name, but different user numbers in /etc/passwd a tar file, for example, will have made the files the wrong owners when you "untarred" the file.

Otherwise, OVH.com have a really good imap to imap move utility
 
Last edited:
I would recommend you to get in touch with your host as they will be better able to assist you with this.
 
It's actually not terribly hard to do this, and I've done it before for clients. Here's how to do this

#1: Enable SSH (this is important) for the account on the new server
#2: Setup ssh keys and establish the key on the new server
#3: use something like the following rsync command, as a cron job

Code:
rsync -azv -e"ssh -pport"  ~/mail/ newserver:/home/user/mail/

This will effectively sync over mail from the old to the new server as frequently as you have the cron run. I typically run it every 10-15 minutes for the first few days after accounts are transferred.
 
You can easily migrate mails from one cPanel account(cPanel A) to another cPanel (cPanel B) account by simply creating the email address manually via cPanel and once this done you can remove the mail directory on /home/user from cPanel (cPanel B) and copy the mail directory from the cPanel (cPanel A) to it and update ownership to make the mails working .
 
^^ actually no. That's not a good idea
The reason that's not a good idea? DNS

If you're moving accounts from server A to server B, you need to leave email intact for both servers. Don't delete any accounts, or any mail. The best and safest approach is the rsync method used above (and not just because I mentioned it).

If you delete the accounts, or the directories prematurely, bad things can and will happen. Clients will get upset because their clients couldn't mail them (rather it went to the wrong server), etc.
 
DNS Issues

How long it takes to move your domain can be changed.

1. Look at you DNS settings and see what your TTL (time to live) is.

This is how long an ISP or client can cache the answer for a DNS lookup from your domain. (In this case an A or MX record lookup).

14400 = 4 Hours. change 8 hours before the move
...
86400 = 24 Hours, change 48 hours before the move

Change this to something like 300 (5 minutes).

If you do this long in advance like 48 hours, then when you are ready to move it should only take 10 minutes (twice the TTL) for DNS to completely move.

Email
Rsync is a good method to do this, but as long as the files end up with the necessary permissions this shouldn't matter.
 
In theory, yes. However, believe it or not, even with those values (and they're pretty standard, have been for years), there are still those that don't follow that practice. I've seen this time and time again, where DNS has been changed (or left as is, since it was default), and even days later the mail still goes to the old server.
 
You can use 'imapsync ' command to migrate the emails from one cPanel server to another.

Following is the command -

imapsync --host1 server1.example.com (source) --user1 Your email address --password1 (password on server1) --host2 server2.example.com (target) --user2 Your email address --password2 (password on server2)
 
imapsync is nice if it works - I've never had luck with it working for some reason.

I usually just add both email accounts to my mail client as IMAP and then drag and drop the messages over. That said - the last time I had to do this was several years ago.
 
If both are cpanel , then rsync will be the best option as we can simply copy paste the passwd and shadow files as well if needed.

If you are moving mails from cpanel to non cpanel or vice versa then imapsync is the best and proper tool which I have seen for migrating mails . The only issues with imapsync is we need to have password for all email accounts in both source and destination server.
 
Hi,

it can be easily migrated from server root (whm) access, follow the below steps.

1- Login to WHM
2- search "copy an account from the other server"
3- put another server ip, user, and password.
4- Click copy account.
 
Last edited by a moderator:
Except this doesn't do what the OP asked. That won't keep mail up to date.
I don't see that they are asking for or requiring that.

What it looks like to me is they're copying from a non-empty folder into a non-empty folder and they are being asked if they want to overwrite the duplicates.

I would imagine the duplicates are likely the same but taking a good backup before working with the files is always a good idea.

That said - the OP can either overwrite or skip the duplicates - and then see if they get the result they want.

If they do want it kept up to date - RSYNC on a CRON would do the trick most likely.
 
The best choice is to contact your actual hosting provider and ask them to do it for you.They have a lot of transfer tools and they can move your entire accounts in just seconds.If you want to do it manually go to your old cpanel and backup your full directory.From the archive you will need to upload your mail folder from your root directory and your email aliases.
 
The best choice is to contact your actual hosting provider and ask them to do it for you.They have a lot of transfer tools and they can move your entire accounts in just seconds.If you want to do it manually go to your old cpanel and backup your full directory.From the archive you will need to upload your mail folder from your root directory and your email aliases.

Exactly as above, get your hosting provider to migrate them for you, we do this all the time so have many tools and lots of knowledge at our disposal.
 

Forum statistics

Threads
81,042
Messages
248,663
Members
20,688
Latest member
netcrohosting
Top