So, your WordPress website is online and doing well. Traffic is good, everything is fine, nothing bad has happened and you’ve been backing up frequently. Except…
Except you want to perform maintenance and web development on your site.
Installing a plugin, editing code, changing the theme, upgrading to the latest version of the WordPress software. Theoretically simple stuff.
1. How do you propose to make back end changes? Are you poking around in functions.php? Surely, surely, surely you know not to tamper with the live software/code and risk breaking the public website?
You’d be surprised by what can wreck a WordPress with a few innocently misplaced clicks.
2. What happens if/when you discover the WordPress backup you thought you’d successfully created is incomplete or contains errors?
Many webmasters dutifully create a database backup but don’t bother to check that it works.
3. Do you want to avoid website downtime, irritation to customers, disruption to business communications and loss of income?
WordPress websites break. It’s a PHP site running a MySQL database. With so many plugins and themes, compatibility issues seem to strike with perfectly bad timing.
Run an Identical Offline Copy of Your WordPress Website
The solution to website development hell is to do it in safely and offline.
You want an identical development version of your business website running on your computer at all times.
It’s development/dummy website in which all links are working, all images are present and the dashboard is fully accessible. It’s a test tube clone.
The difference between the offline and online site is that the latter is publicly accessible on your remote web hosting server while the offline version is for your eyes only.
Inside the localhost your public URL is swapped out for a local server URL.
http://www.smallbizgeek.co.uk becomes http://localhost/smallbizgeeklocal/
(There’s a video tutorial at the end of this post if you want to skip my explanation)
Have a WordPress “Fire Drill”
Never assume your live/public website on your webhost is somehow immune to disaster, because it’s not. Out of the box, WordPress is not all that secure, and I have even pointed out a WordPress vulnerability that can be patched inside phpMyAdmin.
Anyway, why wait until the shit hits the fan to find out whether you can or cannot restore your website?
Can you afford to take risks when you could just get into the habit of cloning your site to a localhost?
A stitch in time saves nine.
How often do you change your website? Are you adding new things regularly?
The basic idea is for you to update the offline/duplicate version of the website whenever the live website is updated.
It’s not just coding/development. What about all that valuable content. Don’t you want a working duplicate of all that too?
Assuming you already backup your database and web directory frequently, you’ve got most of what you need to set up your duplicated development site in the localhost.
There are three parts to the process of cloning your website:
- Download your database from the remote server database admin
- Download any recently modified folders from the remote server directory
- Import both of the above into the offline server (localhost)
Of course, the last step requires the installation of software to set up your offline server.
The excellent and well known WAMP server (Windows, Apache, MySQL, PHP) is a free server stack ideal for a CMS (content management system).
This seems to be the staple software for most serious WordPress users wanting to develop/test offline using Windows.
By default WAMP is installed to C:\wamp and creates a directory called \www\ which acts as the root directory.
I prefer WAMP for larger websites but you might prefer InstantWP initially if you’re new to all this.
The default root directory for Instant WP is a folder called \wordpress\ which is the equivalent of WAMP’s \www\ folder.
Local Web Directory
Whichever type of local development server you decide to install, you’re going to need to keep all the directories up to date.
About twice a week I clone Small Biz Geek to WAMP. I also copy the /wp-content/ folder into the C:\wamp\www\ folder on my computer.
You’re going to need to access your remote server web directory to actually copy the files over to your computer. Filezilla is very good (and very free).
Normally, the only remote directory you’ll need to copy is the /wp-content/ folder, since that is where uploaded images and plugins are saved.
Whenever I add new images to a post using the media uploader, WordPress, by default, automatically saves these to /wp-content/uploads/ and so I’ll be sure to copy this to the localhost equivalent.
Beware of WordPress Software Updates
You might know already that updating the WordPress software can break your site. It’s happened to me and countless others.
When WordPress needs to update I’ll test it on my site locally. If the software upgrade goes without a hitch, I’m then confident I can safely do the same on my live website.
Similarly, if any plugins updates behave badly, it won’t matter if it’s happening inside the local version of my website.
When Do You Need to Clone/Copy?
Let’s establish two common scenarios in which webmasters need to copy/clone a WP site:
1. Website is Offline/In Development
If the site is being developed before the public launch it’s usually created inside a local development server (the aforementioned localhost).
This stage of the build is like working in a shipyard. The incubation period protects your fledgling website until it’s ready to go online.
Indeed, once a site is completed, it will be cloned to the public webhost.
2. Website is Online/Live
If the site is already live and accessible by the public, it is on a remote server (webhost).
Each time a webmaster makes a major change or update, the website ought to be cloned and loaded into their localhost.
Your localhost is not only a shipyard, but also a kind of maintenance pit stop.
How to Clone Live WordPress Site to localhost
In the video demo below I’ll be cloning the site and reproducing it in the WAMP server manually. That means no plugins will be used.
Besides WAMP, the following tools are used in the video:
- phpMyAdmin (MySQL database administration interface)
- PuTTY (SSH Linux command line emulator for Windows – my favourite method for database admin)
- Search Replace DB Master (free script for changing database URLs without breaking serialised data)
Moore’s Law says, “Anything that can go wrong will go wrong.”
Because of this, I believe the phrase “better a little caution than a great regret” is wise.
You might have put hundreds or even thousands of hours of work into your site. If you’ve ever lost data, you know how painful it is.
In business you cannot be prepared for EVERY eventuality. But you can at least mitigate some of the unpredictability.
Do the right thing and steer clear of any unpleasant situations that arise from someone or something buggering up the public version of your site.