Website & Email on a different server

Cloud9

Well-Known Member
Sep 17, 2012
60
1
58
UK
cPanel Access Level
Root Administrator
Hi

I have a website and the email and website is all on the one server (a direct admin server)

What I need to do is have these different as in:

1. Website is an Invision forum board and this is being moved to their cloud hosting so I need the website part of the domain to be pointed to there
2. The cloud hosting IPB provide doesn't do emails so I will have a cPanel account (not whm) for just the emails (about 20 on the account) at present
3. I need to manually move the DA emails to the new cPanel hosting for emails

In essence

At present

Emails and Domain on DA server called A

Need to

Domain pointed to IPB cloudhosting server B

Emails pointed to cPanel account Server C

Once B&C working dump A

Need help with setting up the DNS/MX records etc as I haven't done anything like this before

The domain is held at Namecheap so presume I would alter the DNS records there (at present its controlled by the DA server)
 

kodeslogic

Well-Known Member
Apr 26, 2020
293
103
118
IN
cPanel Access Level
Root Administrator
Once you migrate your website data to IPB cloudhosting server B and emails to cPanel account Server C then you'll have to

- point the A record for the domain to IPB cloudhosting server B so that the website resolve from there.
- point the MX record for the domain to cPanel account Server C in order to route your email from the Server C

This needs to be done on your DNS server.
 
  • Like
Reactions: cPRex

Markif

Member
Nov 9, 2016
23
2
78
Toulouse
cPanel Access Level
Root Administrator
Looks like a work for DNS and some planning / todo-list.
As I understand you will quit the DA server, you should first put the DNS at your domain-name provider so its independent of your web / email servers.
Remember DNS changes takes some days to propagate through the internet.
Once DNS stable at your domain-name-provider (or other DNS provider), make the cache-time of the DNS records smaller (so other DNS servers will ask for the new setting faster).
The website goes to the cloud, OK, it will have a new IP -address. That has to be put in the A-record of the DNS of your domain-name. The www. prefix is often solved with a CNAME record (www CNAME mydomain.com)
Then the email. I suppose you want them on CPANEL (we are on a CPANEL forum :) )
If you have only one domain they have "solo" license.
If your mail is already on a CPANEL server you can use there "Transfer or Restore a cPanel Account"
If the source is not on a CPANEL server you can use tools like imapsync.
The howto is different if you know or not the passwords of the mailboxes, or if you need to apply new passwords.
Once the mail transfer is over to the new server, change the MX-records of the DNS to point to the IP of that new server.
As this DNS-change will take some time to propagate, you will have to run different times tools like imapsync until you see there is no mail entering into the old server anymore (it should go to the new IP you have put in the MX record).
This is typically something to start on a Friday night, and repeat during WE, so users have all OK when they come again in office on monday.
If you can set back their passwords they will see no difference.
If you don't know their password you can always try to copy their entry in the
/home/<UNIX>/etc/<MyDOMAIN.COM>/shadow
file (on CPANEL)
Or you will have some communication of new passwords and howto change the password in their mail-client.
Best prepare users before, so they don't panic on Monday that their mail does not work !
If you have a small number of boxes you can offer some remote config via things as TeamViewer to make your users happy.
Also change on time in the DNS the hostnames that your users use to access the mail services : mail.mydomain.com ? or smtp.mydomain.com, imap.mydomain.com, etc...
Best to test first with one test mailbox...
CPANEL can very good work with only mail on it, and web elsewhere : il just how to what the DNS entries point to.
 
  • Like
Reactions: Cloud9

Cloud9

Well-Known Member
Sep 17, 2012
60
1
58
UK
cPanel Access Level
Root Administrator
Thanks @Markif

The new server for mail will be a cPanel server - not that keen on DA to be honest - its a bit "clunky"

There is only 1 domain on the DA server - dedicated server - for 1 website (although it runs on a subdomain)

I have all the passwords for the email accounts and also have root access to the DA server

Is it possible to copy the mail boxes over from the DA server to the CP server with scp or the such like

I have never used imapsynch and there are quite a lot of emails going way back to 2012/14 ish

At present the DNS is at the DA server and at Namecheap the DNS is set to ns1.SERVERA.co.uk and ns2 respectively

So if I change the DNS back to name cheap as a first thing to do and set the web and mail up on there
 

Cloud9

Well-Known Member
Sep 17, 2012
60
1
58
UK
cPanel Access Level
Root Administrator
With the A record in host I presume I need a few of these, like www & ftp - anything else ?

MX record for host presume I need mail

The server a has a subdomain that is mainly used so presume subdomain as an A record as well ?

And do I need a CName in any thing ?
 

Markif

Member
Nov 9, 2016
23
2
78
Toulouse
cPanel Access Level
Root Administrator
I have all the passwords for the email accounts
this will facilitate the migration
Is it possible to copy the mail boxes over from the DA server to the CP server with scp or the such like
I don't know the DA server, so I can't comment on this possibility.
On the other hand, what is certain is that the DA server must have the IMAP service, just like CPANEL.
So using imapsync will work anyway.
In addition, you will probably not be able to switch the mail flow at once to the new server (due to the DNS cache and the DNS propagation time of the changes), so you will probably have to redo the transfer of some new mails still comming in to the old server several times.
Once you have created the imapsync configuration file you can run it as often as needed without much effort.
I have never used imapsynch
There is a good howto on imapsync/imapsync
It looks impressive, but you only need a few options. The quantity or the age of the mails is not a problem, it will take time that's all.
Look at the part "HUGE MIGRATION" and create your text file "file.txt" as showed,
Code:
user001_1;password001_1;user001_2;password001_2
user002_1;password002_1;user002_2;password002_2
user003_1;password003_1;user003_2;password003_2
user004_1;password004_1;user004_2;password004_2
and create a second file for the shell script, say "migrate_mail.sh"
of course replace OLDSERVER.COM with the hostname or IP of your old server, and likewise with NEWSERVER.COM
Bash:
#!/bin/sh
{ while IFS=';' read  u1 p1 u2 p2; do
            imapsync --host1 OLDSERVER.COM --user1 "$u1" --password1 "$p1" \
                     --host2 NEWSERVER.COM --user2 "$u2" --password2 "$p2"
     done ; } < file.txt
Give it executable rights.
Bash:
chmod migrate_mail.sh +x
and execute
Bash:
# ./migrate_mail.sh
First use the "--dry" option, so nothing happens in real and you can see of all is fine, and first try with only one test mailbox.
Look at an example here https://imapsync.lamiral.info/examples/imapsync_example.sh
At present the DNS is at the DA server and at Namecheap the DNS is set to ns1.SERVERA.co.uk and ns2 respectively
So if I change the DNS back to name cheap as a first thing
Yes, since you are going to quit the DA server, you have to move the DNS first.
If Namecheap allows DNS to be configured there, why not.
You could also configure DNS on the new CPANEL server and make the NS records at namecheap point to the new CPANEL server.
Think about it that a DNS change needs a few days to propagate.
And each correction of any error takes the same time to propagate too ;)
first thing to do and set the web and mail up on there
No, only DNS goes to namecheap (or other) or to the new CPANEL server first.
keep at the start mail and web on the old server.
Only once DNS is stable on his new place move the web to his new cloud-server,
and change then the A record of the domain to the new IP of that cloud-server.
For the mail
First create the mailboxes on the new CPANEL server (with the same usernames / passwords you have)
and only after that change the MX record to the new IP of the new CPANEL server (or you will lose new incomming mail....)
You can run imapsync after that if you use the IP of the old and new server so you do not have to wait the DNS-propagation.
www & ftp - anything else ?
It will be necessary to copy what there is now.
Usually the A record is for the main domain, and CNAME can be used for all hostnames that point to the same IP.
But as you now will have different IPs for the web and the mail, you will have to point the domain and the www alias to the webserver IP,
and create A records for the hostnames that your users uses in theire email-client to point to the new CPANEL server.
The server a has a subdomain that is mainly used so presume subdomain as an A record as well ?
I don't quite understand, so it's a little dangerous to say something. Let's say if the subdomain points to different content than the main domain, then yes, an A record might make sense.
If it's just a service (like POP, IMAP, SFTP, etc.) a CNAME is fine, but the difference is not that big.
On the other hand, take care to copy and update the hostnames that your users have configured in their email client

Before starting, make a todo-list with the order of what you are going to do, and the wait times for DNS propagations.
And above all: make sure you have a backup of everything before you start ... you never know.
Email migration is the trickiest because it's a continuous flow, and users are easily irritable when it doesn't work.
So once the boxes have been created on the new CPANEL server, I would do the MX modification and the hostname modifications (A records and CNAME records) that the users use in the email-client on a Friday evening, then run the mail transfer script via imapsync.
If all goes well, users will find their email on Monday morning.
 
  • Like
Reactions: Cloud9