A client of mine was having a lot of trouble with his shared hosting and finally made the decision that enough was enough. Below I will write down the whole process of transfering from an unknown hosting to Godaddy.
I will be using www.example.com (with IP: xxx.xxx.xxx.xxx) as the name of his website (domain) and email@example.com as the email address that needs to move, replace it with yours.
The challenges that we faced were:
- Moving 5 years worth of email from one webmail to another considering
- Transfering over 2.5GB from one server to another
Step 1: Setup Hosting
This is the step where you decide to move away and select an appropriate hosting for your website. We will use Godaddy as a default since many of the hosting processes are common amongst the top providers and also it is the most recognized one.
Godaddy offers a free domain with your hosting, use it as you wish.
- Once the hosting is ready setup your cpanel account
- Go to Domains > "add on domains" and add www.example.com as an addon (this will allow you to be prepared once you wish to redirect your domain to this server). Basically this prepares the hosting to accept the domain call
- Lets say IP address is yyy.yyy.yyy.yyy
Step 2: Setup Emails
Now we must create the email(s) that exist on the previous server; as you can see we are basically for now shadowing the server with all the data that it should have.
- Go to cpanel > Emails > Email Accounts
- Create the same email(s) that exist currently (make sure the domain is @example.com)
So now we are ready for the hard part to begin. Lets start with the webserver transfer.
Step 3: Backup Files
You need to connect to your current server using SSH, to do that you either use PuTTY or if on mac you can use the terminal. Connect with your hostname / username / password.
Below are some important instructions you need to know when on a server:
- To view the files inside a current directory type: dir
- To move into a director type: cd foldername
- To move one folder back type: cd ..
- To zip a folder type: zip -r filename.zip foldername
- To unzip a zip file type: unzip filename.zip
- To create a new folder type: mkdir foldername
- To delete a folder type: rm -rf foldername/
- To delete a file type: rm filename.ext
- To move a file from one folder to another: mv filename.ext newfoldername/
- To set permissions to a folder and the files inside it: chmod -R 777 folder (777 giving full access to the folder and the files, which is not good practice and can reduce security)
- To paste something you have copied with ctrl+c just right click no need for ctrl+v
- To make apache owner of a directory and the directories/files inside it: chown -r apache:apache foldername
with the use of dir / cd and cd .. find the directory that holds all the webserver files meaning the folder that holds either public_html or www.
Once you find it (let's say you are on home/ which has public_html inside it) you type:
zip -r backup.zip public_html
and let the backup happen.
Once the backup is made we need to move the file into a location where it can be downloaded by a URL (make sure this is quick as anyone can access it) in our case a move to the root would be sufficcient:
mv backup.zip public_html/
And now it is ready to download ... but do not!
Step 4: Transfer Backup to new Server
Imagine this file backup.zip could be an extremely large file very hard to download and re-upload. What we must do is connect with SSH to the new server and upload the file in the appropriate directory.
Godaddy does not offer SSH access immediatly to users on shared hosting and in order to be able to access you must whitelist your IP by going into: cpanel > Security > SSH/Shell Access, enter your IP address and wait for confirmation screen. Now ...
- Open PuTTY/terminal and enter the IP address of your new server (not the hosting name)
- Enter the required username and password and login
- using the above instructions try to find and go inside the folder where you have added on the domain (most probably somewhere like public_html/example.com/)
- Once inside the folder just type:curl -o backup.zip http://example.com/backup.zip
The download now begins with a much faster speed than if you were to download and re-upload.
Once the backup is complete just unzip the file: unzip backup.zip
Step 5: Sync Emails
Now this is the tricky part. How can we sync our current email mailbox to the new one?
For this I will give you my approach but I am sure there are other ways to setup. I have used a third server that runs on CentOS 6.0 and installed a little software called imapsync which given by the name, syncs emails with each other. If you are running any other server just google "imapsync install yourservername" and there will be tons of guides on how to do this. For those using CentOS follow the below process:
- Enter the following: rpm -i http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm
- Then you must go into the folder user/bin/ found on root and type: yum install imapsync
This will install impasync (hopefully) if not then you must contact your hosting and ask for their assitance as there could be issues with PERL or other factors involved.
Let's say those issues are all resolved you must make a call like this (just edit the details accordingly such as hostname, email, and password):
--host1 xxx.xxx.xxx.xxx --user1 firstname.lastname@example.org --password1 youroldpassword \
--host2 yyy.yyy.yyy.yyy --user2 email@example.com --password2 yournewpassword
And let the move happen. This could take hours given the number of emails.
Step 6: Database Backup
For database backup we have gone the easier path which is get a backup of all our databases using phpMyAdmin from the old server and importing the file into the new server. In cases where the files are large you may use the assistance of your hosting support.
Step 7: Edits and DNS/MX Record Change
You must not go to the source of your files on the new server and edit the database connections, hostname, and passwords to meet the change.
In order to finalize the work you must replace the DNS of your domain to point to the new servers. The same goes with MX Records, I assume this should not be too challenging if you have been able to reach this far, just a quick change and a few hours of wait.
With this I conclude a 100% migration of servers. Hope it helps someone out there.
comments powered by Disqus