If you like tinkering with things you will have inevitably run into the scenario where you had something which was working, albeit maybe no just quite how you wanted it. After looking through manuals and reading a bunch of documentation it’s time to play around with things that may seem a bit foreign or off the beaten path. What generally happens to me is that I’ll mess with something in an effort to make it better and then end up screwing up everything.
I’ve run into this scenario more often than I care to enumerate. What I’ve learned after spending much of my time trying to undo my mess created by playing with a setting that shouldn’t have been tweaked is that you always need to make a backup! One other thing I’ve learned is if you can copy or practice on something that you don’t mind destroying that is even better!
I administer not only my blog here, but I also am the webmaster for a RC club. I’ve been wanting to work on some theme and plugin options. Doing this on my personal site isn’t something that concerns me. If I screw up my personal site I loose some articles and a bit of a hobby. However, if my club site goes down then the public face of our organization isn’t accessible by members or those searching for RC clubs (this is a big deal).
Over the past few days I’ve been trying to get it where I can have a staging or test environment that I can completely destroy and not loose any sleep over. What follows are some tips, ticks, and helpful points to get a WordPress site running locally from a backup of your current production site!
Backing Up Your Current Site
In this post I’ll be giving you steps to backup your site using the Duplicator plugin. In follow-up posts I’ll show you how to setup a local server and restore the site so you can run it. Over the next few posts I’ll detail setting up a hosting environment and restoring your backup locally.
You should already be backing up your site. There are too many stories of WordPress sites getting hacked and being part of spam or botnet type operations. If you were to find out that your site was compromised why fret over lost work when you can identify when the intrusion took place and then restore to a point before that time. If you’re running a managed site from one of the many WordPress hosting sites out there it is likely they’re already doing it. It would be good to go a step further and do your own snapshots.
The first thing you need to do is get a restore-able copy of your WordPress site. Duplicator is a plugin that can duplicate, clone, backup, move and transfer an entire site from one location to another. This is exactly what type of backup you should be performing. If you can’t restore your backup anywhere then is it really a backup?
You can install Duplicator like any other WordPress plugin. Once installed you can walk through their documentation for creating a package. One thing you may want to consider when creating a Duplicator package is to filter out your uploads folder. On my personal blog I’ve uploaded a significant amount of images and other media. If I were to include this folder it would make the backup file incredibly large. On my much smaller site with much smaller amount of media the size of the site portion of the backup was around 250MB. The size of my personal site is many times larger. If you’re backing up to bring the site local for testing then you may not need to pull down all the content that you’ve uploaded for use inside each of your posts. Depending on your hosting Duplicator will warn you if it thinks the backup will fail because of the size of your site. Just be weary of how large your upload folder has become if Duplicator has issues creating a package for your site.
You can use the archive section to tune the package. The files section is the important tab. As I mentioned above, the size of your package can become problematic. The two key paths to ignore will be the uploads and cache folders. The uploads folder contains all the images you’ve uploaded to the site. These folders can be ignored if you’re just going to be testing things locally. If you’re going to be completely backing up your site then you might not want to exclude the uploads folder. The cache folder may actually cause problems if there are items in it. This one is pretty much safe to ignore at any time.
Once you’ve backed up your site you’ll want to restore it somewhere. I’ll cover that in a bit, but if you already know where you’re going to restore the site then you can put in those default. Of course, you can change these values when you run the installer.
When you click next the Duplicator plugin will run a check on your settings and on your site. Any alerts will show here. Follow any instructions to resolve the warnings or errors. Click the build button and you can wait while Duplicator builds a backup of your site.
Once your site has been duplicated by Duplicator you can download it through the web interface. Most of the time this can be rather slow. My perferred method is to fire up WinSCP and grab it right from the wp-snapshots folder. Whatever method you choose grab everything, the JSON, PHP, SQL, and ZIP files.
Now it’s time to restore your site locally. Before you can do that you need to setup a server to run your WordPress site locally.