I know moving your wordpress blog to other host can be sometimes very quick as just a matter of clicks and you are live, but things doesn’t always work as expected especially when you are moving to a shared hosting providers though sometimes using plugins you will actually do it quickly. Here I’m sharing tricks and ideas that can really help you later.
This is completely from my experience of moving my blog from Amazon AWS EC2 to godaddy, which has lots of challenges and seemed impossible tasks to be achieved. This is a story and not a how to guide, so if you are looking for a tutorial this is not the right place but you can continue reading for a real impossible like challenge and the solution I figured.
Oh guys this is really going to be a long story, let me start with why I wanted to migrate my wordpress blog from AWS EC2
I was running out of resources of micro instance and mySql server service was getting stopped everyday. The first thing I could do was to move the database somewhere else so I choose AWS RDS for mySql Server, it worked fine for a few days but later my ec2 instance was going unstable, The website goes in unreachable state and even I can not connect to the instance over ssh. Every time I want to connect through ssh I had to restart the instance. This was the case for a day and I tried stopping and starting the instance but still no luck. Heres what I did to fix the issue but could not solve it.
- Moved database to RDS
- Rebooting the instance
- Stopping and Starting the instance
- Created the instance AMI image and Started a new Instance
You would probably say I should simply upgrade my instance to small or medium but I really do not have money for that costly service from AWS so the best option for me was to migrate somewhere else such as a shared hosting or best option a wordpress hosting so I decided to move.
Purchased a managed wordpress hosting from godaddy
This is the time my exams were going on and I wanted my blog up as fast as I can, so I purchased managed wordpress hosting from godaddy as there was a discount going on. This is the best plan when you don’t want to take any headache of managing your blog, they ensure your blog will be up and running every time.
Preparing to take backup of blog from EC2 to be uploaded to godaddy
I exported my database and created a ZIP file of the wordpress files of the blog. The size of the zip was nearly 500 mb. Now I had to download the file from ec2 which is yes I could download the 500 mb file easily to my laptop when my instance could stay live for a time, as I said above the instance just goes unstable at a period of time. So heres what I did to download the zip file.
- Configured AWS cli with my credentials on ec2 instance
- Created a bucket on AWS S3
- Uploaded the zip file from ec2 to s3 bucket using AWS cli
Copying the file from ec2 to s3 was blazing fast. It was done in a few seconds. Now I downloaded the zip file from s3 to my laptop and made the database and wordpress files ready to be uploaded to godaddy.
Problem with managed WordPress hosting at Godaddy
Now I was prepared to upload my site to goddady and I logged into my account, opened up the hosting package I purchased which is the basic managed wordpress hosting. Now imagine what I just saw, there were only 2 options YES ONLY 2 options.
- Create a new website
- Migrate from previous hosting provider
I was completely doomed when I found that I do not have ssh access for this package. I didn’t have sFTP access also. I just created a new website and from there got the sFTP details that I can use to edit files of the fresh wordpress website which is live. I thought, by connecting to sFTP I can change the default installed wordpress files and replace with my website files. This was the option I could see at that time but, what ! seriously uploading that many files. I uploaded the zipWarchive and thought could unzip it, but no way I can not. I was really in need of ssh at this time but I was not allowed to use it.
I had to choose from the options godaddy was providing and I just got an idea that I can setup the blog on other hosting provider such as a free hosting for temporary and then use the migrate option of godaddy, this was the only hope for me. Wait, really! why I can’t migrate from my existing website ? Well as I said the server just goes down every few minutes plus I had to setup FTP server to provide FTP details in the migrate option.
Setting up blog on free hosting ( lots of problems here )
I created an account at a free hosting site and got the free domain they were providing. I got the cPanel so I could upload my site here easily, but I really had bad luck and nothing was going right for me. Guess what, I can not upload that much big file here. I gotta break it into smaller files of less than 9 mb, o yeah I can not do that much time consuming work as well.
PHP comes to the rescue
Would you ever think of downloading file over server to server using PHP ? It just triggered to my mind. I can download zip archive from AWS S3 to this hosting space using PHP, yes you heard that right. So I created a PHP script that can download my zip archive from S3 to my free hosting space. I run the script and my file is ready on the free hosting space, yeah I made my blog zip archive public on S3 at the time, anyone could download it if knows the URL. I made it private as soon as download was complete which is under a minute.
Unzipping the archive
Now I had to unzip the file and import the database. It was again not easy as I can not unzip the file which are large in size. Free hosting services are always limited and that is obvious. I had a ssh console available on website only. Which is limited to commands I can execute. There were commands to copy and move and some more. But not the zip or unzip command which I can use to unzip the archive. There were bzip2 and gzip commands available so I thought of creating archive using those tool and again download the archive from S3 to this space.
But now I can not archive directories using those tools. The only way it can be done is by using tar, but neither tar was available on ssh console. At moment I thought I should just leave it and think of something else, but again PHP comes to the rescue and I would ask again, would you ever think of unzipping a zip archive using PHP ? I created a PHP script that could unzip the zip file on the same directory. I got the files unzipped, exported the database and my blog was live with a few changes such as changing site url and wordpress url through phpmyadmin. I can now use the migrate option from godaddy to move my blog to godaddy managed wordpress hosting.
Setting up blog at Godaddy
Migrating took around 2 hours and my blog was live on godaddy on a temporary domain they provide for free. I updated my DNS to point to godaddy and now I can use my domain to access my website. The next problem starts here, changing the website address again to https. As the website was migrated to godaddy it was only http, I can use the cloudflare flexible SSL but I can not change my site address URL of the website through admin dashboard because it is in the control of godaddy managed hosting as this is a managed wordpress hosting. Using the managing portal I can only change the domain, not the address such as http or https. But this one was easy, I just accessed the phpmyadmin and changed the site address url through the database and it worked fine.
When I saw the time it was 3:00 AM, this migration took more than 16 hours. I thought of sharing this experience because the PHP part of the work was really amazing for me and could help others also. If you liked this story please share and comment.