For migration of user accounts between cPanel servers, there is a superb “Transfer tool” which is provided and is part of Cpanel. With it, you can simply migrate all data from one server to another. But what about when you have the same accounts on both servers and you don’t want to overwrite data on a new server? I had one account for which the only email was necessary to transfer. This is not something transfer tool can do because I didn’t want to overwrite account.
If you have many email accounts and you don’t know passwords for them, it is realy pain in the ass to change all passwords and make transfer via imapsync. But luckily, you can simly copy all email accounts from one Cpanel server to another by copy user’s “passwd” and “shadow” file.
Here is how you can migrate all email accounts from one server to another without changing username/password. All passwords will be transferred.
First, make sure that domains for which you want to transfer email is already on new server. Then you’ll have to copy passwd file where all users are saved and then shadow file, where all passwords for those email accounts are saved. Those files can be found in /home/username/etc/ directory. If domain directory does not exist, you can simply copy directory to new server:
[root@cpanel]# rsync -av /home/username/etc/mydomain.com firstname.lastname@example.org:/home/username/etc/
You should now see all email accounts on new cpanel server. Now you have to transfer email data also. This is under /home/username/mail/mydomain.com/.
[root@cpanel]# rsync -av /home/username/mail/mydomain.com/ email@example.com:/home/username/mail/mydomain.com/
Now all email is transferred on new server. It is good practice to fix permissions of all email data. Cpanel provides the script for this. Run mailperm script on new server.
[root@cpanel2]# /scripts/mailperm username
You should have now have all emails on new server, with all data and old passwords.