Sandbox Plugin Creates a WordPress Test Environment in Two Clicks

photo credit: Blixt A. - cc
photo credit: Blixt A.cc

A test environment for your WordPress site is an important part of being able to ensure smooth updates. It also allows you to test new plugins and themes without affecting visitors. However, creating an exact copy of your site in the same environment is no simple task. There are many commercial plugins and WordPress hosts who offer one click staging environments, but an easy-to-use free option has been somewhat elusive until now.

Today I’d like to take you on a tour of the new Sandbox plugin, which is now available on WordPress.org. With just two clicks, this plugin creates an exact copy of your WordPress site on your existing hosting provider. The staging environment is completely independent of your site and is hidden from visitors and search engines. The Sandbox plugin also gives you the ability to create multiple sandboxes in order to test different iterations of your site and/or its extensions.

How Sandbox Works

I tested the plugin and can confirm that it does exactly what it says it will do. Here’s how it works:

  1. Sandbox copies your database tables into a new set of tables with a different prefix.
  2. Data within the new database tables are updated to reflect the sandbox prefix
  3. Sandbox copies all files a new folder under the sandbox directory.
  4. The plugin updates the configuration file within the sandbox to support the unique sandbox database prefix

Let’s take a quick walkthrough of setting up Sandbox on a live site. Once you activate the plugin, a new Sandbox menu item is added to the admin where you can create your first test site. The plugin will warn you to backup your site before proceeding.

add-new-sandbox

Next, you’ll be asked to fill in the details for your test site. Simple enough, right?

create-sandbox

The plugin gives you updates as it is creating your test site and will confirm its success at the end of the process. This may take a few minutes, depending on how large your site is.

creating-sandbox

Once you activate your new sandbox, you’ll be navigating your test site within your browser. An alert box at the top will let you know which site you’re on and there’s a link that takes you back to your live site at any time.

Concerns and Feedback

Sandbox is not a perfect plugin, by any means, but I think it’s an excellent starting place that could develop into a solution for setting up quick test environments. My chief concern, however, is that it’s difficult to know when you’re in the sandbox, despite the notice at the top. The URL doesn’t change and your test site is virtually indistinguishable from the production site. One improvement I’d suggest is a larger, more prominent notice that makes it clear which site you’re navigating.

Additionally, if you’re actively using the plugin, it will make your backups enormous, due to all the extra tables in your database. Each sandbox you add will add its own set of tables and this can really add up when testing multiple iterations of your site. The plugin does not remove the extra tables it created within your database when you deactivate and delete it. The good thing is that you can delete the extra tables be deleting your sandboxes when you have no further use for them.

I tested a small blog site and it seemed to take a little while to set up a sandbox. This is understandable, given how much work it is doing behind the scenes. However, I have little hope of the plugin working on larger sites without timing out.

What I love about Sandbox is that you don’t have to go through the process of copying files down to a local test environment that may not perfectly match your production server. I also appreciate the fact that it’s so easy to use and has a very low barrier for entry. WordPress users who otherwise might never explore a staging environment can easily handle the setup process of the Sandbox plugin.

medium_2715060136Stepping into your new WordPress sandbox does have a certain thrill akin to squishing your toes into sand. You know that if you break anything, it’s just sand after all. The Sandbox plugin makes it simple to test updates to your site’s plugins, themes and core. You can also use it to test plugin conflicts without turning off the lights on your production site. Simply create a new test site and go to town, disabling plugins one at a time. Testing conflicts wherein you are encouraged to disable all your plugins is much easier with a test environment that is an exact copy of your live site. The free Sandbox plugin makes it possible for WordPress users at any level to create their own staging environments.

19

19 responses to “Sandbox Plugin Creates a WordPress Test Environment in Two Clicks”

  1. It all sounded great until:

    “Additionally, if you’re actively using the plugin, it will make your backups enormous, due to all the extra tables in your database.”

    I test out plugins and new themes on a local setup using XAMPP

    Only takes a few minutes to set up a new WordPress install and no problem if it all goes wrong.

  2. I installed & activated Sandbox on my localhost WAMP (WAMPServer) server. I have a test-site with 430 posts and 260 categories.

    But, Sandbox was not too happy. It issued 2 errors, in the early steps described above by Sarah. They were:

    Warning: array_slice() expects parameter 1 to be array, null given in C:\wamp\www\wp3\wp-content\plugins\sandbox\admin-table.php on line 122

    This message appeared at the top of the opening screen, after “Sandbox” was initially select in the Admin menu bar.

    Fatal error: Call to undefined function sandbox_edit() in C:\wamp\www\wp3\wp-content\plugins\sandbox\admin-menu.php on line 29

    This message was appended to the “Of course I’ve backed up my site!” reminder, in the second screen, which is produced after pressing the Add New [Sandboxes] button, in the first screen.

    These issues could very well be simply minor matters associated with the localhost environment. I have not looked at the scripts, but may be able to this evening.

    Interesting tool. In a localhost [I am hopeful that], time-out & loading issues may be either absent, or ‘freely’ resolvable.

  3. How does this compare to creating another database and cloning the site into a sub-directory on the same server? I maintain a pretty large development account and regularly have multiple test WordPress installations in separate directories. Works, but rarely an identical environment to where the final site is to be installed. This sounds interesting – will have to try in my copious free time (whenever I get some!)

  4. I love the simplicity of Sandbox. Thanks for writing about it, Sarah!

    I wanted to quickly create, modify, and checkpoint clones of an existing WordPress site, and developed an approach based on the Duplicator WordPress plugin for backups: http://gear11.com/2014/01/wordpress-docker/ Duplicator provides the same kind of “2-clicks” approach as Sandbox, but the cloning process also requires a Linux server (or local virtual machine if you run Windows or Mac) on which to execute the copy. The payoff is that once you are past the setup, you can quickly spool up a clone of any site just based on the Duplicator backup package.

    I’ll have to work hard to get it down to “2-clicks”, but Sandbox provides good inspiration.

  5. I would worry that as it is using the same database, that if the copied tables of the sandbox were to get corrupted while testing, that the entire database might corrupted as well. Yeah, having a backup is good, but if it’s a particularly large database, say in the GB range, restoration can be quite time consuming if restoring from an offsite backup. Having gone through something like that with a cloud hosting situation, I’d have to say I’ll pass on it for any production website that has a database of around 200MiB or more in size. I can see the appeal for a small established website or a startup to test different iterations quickly.

    • Novice help: I used WP Migrate DB free plugin to create an sql file of my local wp databse. BUT, when I try to import that sql file into phpmyAdmin (into my server db) it only imports some tables before crashing. That means, my WHOLE site content ect on my server is unusable. Does the PRO version work better? Can I somehow import the db differently and still keep my 4 months of wp content work? Any suggestions would be appreciated. Thanks

  6. I suggest a glowing border around the page when in sandbox mode.

    We have had one total failure while using it, when we had the sandbox sign up in admin, but our changes were published. In fact it appears at the moment that the sandbox just does not prevent changes to the home page widgets at all, but since we are in our fine tuning stage for a release today that ticket has been deferred to next cycle. It is a great plugin, and WordPress is better for it, but be careful as you get used to it.

    Kurt

Newsletter

Subscribe Via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.