In this post I want to introduce two basic (wordpress) development practices, and the corresponding two FREE tools to make these practices easier to do.
Site Duplication & Backup
As Murphy’s Law said:
Anything that can go wrong, will go wrong.
This is true especially for building wordpress sites. With so many software pieces working together (technology stack and plugins), and updating all the time, it’s highly likely someone would make a mistake and break your site.
To solve this problem, a very effective strategy is to periodically backup your site to multiple safe places like Amazon S3 or Dropbox. For software companies backing up sites and data is already standard practice, and you should too.
Sometimes we also want to bring our sites from one machine to another, for various reasons like making our sites live or switching to a better/cheaper cloud server. For this we can also use the backup technique and copy our sites.
When you have a live site (called “production site” in software community) and want to add new changes, it is not a good idea to directly change your production site, for the following reasons:
- You don’t want to interrupt your site serving your visitors.
- You want to experiment before making the final changes.
- You want to make sure your site is still running if you made mistakes.
So instead of directly changing your production site, what software engineers do is to copy the production site into a “staging site”: a replica of your site which only you could access, and can be repeatedly broken and fixed.
By first making changes on your staging site and make sure it works, you can then copy the changes back to your production site and ensure the new changes work also on the production site.
You don’t need all the data on your production site for your staging site. You just need enough data (eg: a few blogs) so you can test how new changes affect your data.
The difference between staging and duplication is that duplication just copies files and data: it does not need to work as a site. On the other hand staging is to create a working site identical to your production site (but only you can visit), so you can test and see if the new changes work properly.
For periodic wordpress site backup and duplication I use the Duplicator plugin.
Why using this plugin? In order to manually duplicate a wordpress site one has to do the following:
- Copy wordpress folder.
- Copy MySQL data.
- Execute MySQL commands to make wordpress work on the new server’s setting (most commonly the new url).
The duplicator plugin simplifies the above steps into:
- Go to the plugin page. Follow the instruction to create a duplication (zip and an installation php file).
- Download the two files.
- Put the two files into the web folder. Make proper owner/permission changes on the two files for your server software(apache/nginx).
- Go onto the browser and go to the url that points to your web folder.
- Follow the steps to install wordpress and MySQL data.
Duplicator package creation page.
Doing so Duplicator gives the following advantages:
- Easy to manage backups by keeping files and MySQL data into a single zip file.
- Easy to install by web GUI interface.
The WP Staging plugin makes it easy to duplicate your live site into a staging site that only you the administrator can see.
When you create a staging site, the plugin will create a corresponding folder with duplicated files. Then you can go to that folders and make changes at your themes or plugins.
(DON’T change wordpress’ core files: doing so might break wordpress when it updates!)
WP Staging plugin also enables users to select what files in the
uploads wordpress folder need to be duplicated. Doing so users can speed up duplication process by only selecting few files for staging.
WP Staging staging site creation page.
After the staging site is created, follow the instruction and go to url
your_site/staging_name , the staging site will ask you to login as admin in order to proceed. Logging in and you will see the staging site indicated by an ORANGE admin header bar.
Notice the orange bar for staging site!
Now you can add new changes and check on your staging site!
Note: Unfortunately currently this plugin cannot automatically add new changes back to production site, so after you have checked your changes in staging site you have to manually copy the changed files to the production site.