04 Dec How To Migrate A Massive WordPress Site
A client of mine called me and told me their WordPress website was growing too big for the server it was on, even though it was a VPS, that the WordPress site was going offline periodically. They asked me if I could help them migrate this gigantic site.
When I refer to gigantic and WordPress in the same sentence, to me that simply means that instead of megabytes of data in the database they are dealing with gigabytes of data in the database. And instead of thousands of files, there are let’s say hundreds of thousands of files.
Small Biz Now Has Enterprise Level Issues
Luckily I have dealt with both the small and large servers over the years. The real question has always been, can WordPress handle this high volume of DB and File issues. Well, it can, but the issues have to be thought out and a problem like this turns from dealing with minor WordPress hick-ups to corporate-level Unix issues.
Why They Had To Migrate
Their server was just not able to handle what they were doing in terms of server speed, hard drive space, etc. And this was causing the website to be unmanageable. So, it was time to migrate. However, this was not your run of the mill WordPress migration. It had all kinds of potential problems associated with it, like thousands of uploaded files, hundreds of thousands of records in some tables.
Why My Normal Tools Won’t Work
For instance, the database was too big to download using PHPMyAdmin. Not that this is a big deal, it’s just if you have been a WordPress person for the last 5 to 10 years like me, you may not have all the tools in the tool chest to deal with this. I typically use a desktop ftp program to do this stuff, but not for this size. Using local ftp clients means downloading to your Mac or PC. It is not recommended at this level. For instance, if you are not on a fast enough download client, you are screwed…
The reason I am writing this blog entry is so I can grab all those tools again in the following order in order to do this kind of migration again.
Here Are The Steps I took:
- Sized out the proper new server for the client. (My preference is StormOnDemand by Liquid Web, WHM/Cpanel cloud)
- Had the client buy the new server and handed over to me the login credentials.
- Received all the login credentials I need from the original server.
- Created a new website in WHM/Cpanel, generating a new IP.
- Created a temporary domain name for the new site and pointed the DNS to the IP.
- Created a Database Name, Database User in CPanel with the same name as the old DB Name and User.
- From the Shell command line (I use putty.exe) I used the tar command to zip up all the files beneath public_html.
- From the Shell command line I ran a mysqldump of the old database, creating a command line .sql file.
- From the Shell command line I ran FTP as new account name (not root) on new server and Put the tar file (like files.tar.gz) onto the new server. (it was in the multigigs)
- From the Shell command line I ran FTP and Put the .sql file onto the new server. (it was over a gig)
- On the new server from the shell I unzipped the tar file. Remember to position this right above where you want it to land.
- On the new server I switched over to root user (su root) to be able to import mysql.
- On the new server from the shell I ran a mysql import command which updated the database.
- Finally, while in test mode, there were two lines wp_options which need to point to the right domain.
- Make sure all the previous plugins are activated.
- We tested the new site with the temp domain name.
- Once we were ready, we switch the old IP at the DNS record to the new IP.
- Final thing is to rename the site name from the temp domain name to the actual domain name.
- Everything went relative smoothly and the site migrated.
That is all the actions I took, now here are the commands I used specifically:
he tar command to zip up the files to a .gz from right above the public_html directory:
The tar command to unzip the files from a .gz right above the new public_html directory:
The FTP commands I used to connect from Linux server to Linux Server:
The mysql command I used to dump the entire mysql database at the command line on the old server:
The mysql command I used import the entire mysql database at the command line on the new server:
Hopefully if you are reading this, you will use this to reduce the amount of time I took looking around the web for the right commands to do this. You may have to look up those other websites, because each of these commands have dozens of options. For instance, if you need to move more than one file at a time, using FTP, you would have to use mput and not put. So, keep up the good work. I hopefully will use this guide for myself next time.