Watch my Podcast

Follow me on Twitter

Snapshot Backup Plugin for WordPress

I’ve just finished writing a new WordPress Plugin which creates a Snapshot Backup of your entire website: that’s your Database, current WP Core, all your Themes, Plugins and Uploads. The resulting single archive file is then uploaded to an FTP repository of your choice.

UPDATE AUGUST 2012

Due to heavy workload and high demand I can currently no longer find the time to support Snapshot Backup. I may pick up this project again in the future and put new PHP skills to work. Thank you for being kind enough to understand.

In the meantime I’ve discovered a wonderful by Daniel Hüsken which does all I ever wanted Snapshot Backup to do and more: It’s called BackWPup – download it here. It’s way ahead of my plugin and under active development.

———————————-

Disclaimer

I’ve recently been flamed a lot by users who are less than happy with this plugin. That’s tough, so I wanted to state some very obvious facts that most of us do take for granted:

This plugin does not work for everyone. It works fine for me, and I’ve written it for me and my own servers. I’m distributing it in the hope that it will be useful to others, but with absolutely no guarantee that it will work on every Linux system out there.

You are free to use Snapshot Backup, but I strongly advise you to test it on a dummy system before deploying it to your precious live site. Users have reported every possible horror scenario, from complete site deletion to an empty database file. Please test the plugin on your system and check that it creates a reliable backup that can be restored before relying on it to work. Remember: you are using Snapshot Backup at your own risk.

Installation

Activate the plugin and find the option Snapshot Backup in your Dashboard options.

Usage

Snapshot Backup has been designed with ease of use and simplicity in mind.

Once the plugin is activated, you’ll find a new top Level Menu called Snapshot Backup on the left. Under Settings you configure your FTP Details and and additional directory you’d like to back up. Now you can either head over to to Snapshot Backup and create a Snapshot manually, or you can setup automation and let the plugin create a Snapshot for you at regular intervals.

Make sure your wp-content/uploads directory is writable – Snapshot Backup needs somewhere to write files to locally before they get sent away to your FTP server (this would ideally be a second server, preferably with a different host in a different data centre).

In the current release your screen will go blank while the script runs through the various stages. Depending on the size of your site this could take a while… be not alarmed and keep an eye out for the browser status bar. While it appears your browser is working Snapshot Backup is working too. I’m attempting to fix this in future releases and give you a status report of each stage.

Automation

Included since Version 2.0 we have the long awaited automation feature. This creates Snapshots while you sleep and even auto deletes older ones. You can set all this up under Automation and receive a friendly email ever time a Snapshot has been created (optional).

For the automation to work I’m using the WP Cron feature, which in turn relies on your website being visited every once in a while. On live production sites with 100+ visitors per day you’ll be fine, but on low traffic sites you may notice that Snapshots are created at irregular intervals – I’m thinking of test sites with blocked search engines or brand new sites.

To help this along and make the process more accurate you can create a Cron Job which calls the index.php file in your WordPress installation directory (usually http://www.yourdomain.com/index.php)

Screenshots

Snapshot Backup Admin Menu

Success Screen at the end of the Backup

FTP Details Dialogue. Don't panic, your password won't show up -it's an old screenshot you know.

Snapshot Philosophy

Archiving dynamic websites isn’t all that easy and we all tend to forget that because the web is such a fluid thing. The idea of Snapshot Backup is that you may want to create an “as is” version of your entire website for archive purposes. With each click you’ll create a “time capsule” of sorts – this could be for legal, sentimental or security reasons.

Other solutions mirror or sync your installation – which is a great idea too, however if you only notice a week down the line that your site has been compromised then your synced copy most certainly is too. Snapshot makes it easy to go back to a clean version from x days/weeks/months ago.

How does it work?

Snapshot Backup first reads out your entire database into an file. Afterwards it uses the Linux shell command tar to archive all your content. Then it deletes the SQL file and then it uploads the resulting archive file over to your FTP repository.

Please note that this plugin does not work on Windows servers… sorry ;-(

Restoring a Snapshot

I’m working on a simple script that will do this for you. In the meantime you’ll be on your own – with some written guidance from yours truly. Have a look at this article which explains how to restore via FTP.

Known Issues

Even though this plugin is a great idea, it may not work for everyone. I’ve had reports from users reporting that either the plugin creates a 0MB backup file or does not include the database in the tar ball. The following hosts are known to be problematic:

Media Temple

Netpower

MyWebHost

Momwebs

On the other hand, on most hosts this plugin works just fine. If you are in the unlucky situation that you have a problem, please leave a comment and state your web host so I can add to this list.

Alternatives to Snapshot Backup

There are alternatives to creating a full backup of your site such as these (which will cost money):

Or you can try the excellent WP DB Backup Plugin which will read out your database. Following that you can simply login to your site via FTP and copy all your files to your local machine. Not pretty, not automatic, not fast, not convenient… but it’s free and it works 😉

Roadmap: The Future of Snapshot Backup

There are plenty of things I want to add to and improve on this plugin:

make sure the screen doesn’t go blank while the Snapshot is being created

add translation

add the ability to run Snapshot automatically via WP Cron or Cron Jobs done since 2.0

make the admin interface look prettier (and easier to find) done since 2.0

Share this:

Related

Jay is the CEO and founder of WP Hosting, a boutique style managed WordPress hosting and support service. He has been working with Plesk since version 9 and is a qualified Parallels Automation Professional. In his spare time he likes to develop iOS apps and WordPress plugins, or draw on tablet devices.
He blogs about his coding journey at http://wpguru.co.uk and http://pinkstone.co.uk.

Tried on several sites -but got error each time. (FYI) on Shared Business Godaddy hosting – the process completed but file would never download.
Was a good thought…
/Users/my/Desktop/snapshot-20120724-1739.tar.part could not be saved, because the source file could not be read.
Try again later, or contact the server administrator.

Thank you for the wonderful plugin! It has been a standard on my websites for almost a year now and it has made my life easier and saved my neck on a number of occasions.

I am posting this to find out if anyone had found the plugin not playing nicely with w3 total cache (or rather, w3 total cache not playing nicely with the plugin)– I have recently begun to have some issues with long-running scripts originating from snapshot backup crashing my server, and the only thing I can see in common between the cases where I have seen this behavior (aside from snapshot backup) is that it was on sites that were running w3 total cache also.

I really like this plugin and I am determined to find a solution to this so I can resume using it on every site. I just wanted to put this out there and see if anyone else is having the same issue, or if any other readers had any hints as to what might be going on.

I *think* Snpashot doesn’t play well with many shared hosting environments – probably because they like to make sure to mischief is being executed on their servers. Some users have reported that Snapshot was creating multiple long-running backups in the background and have banned it, perhaps something similar is happening at your end.

I’ve currently put development of this project on hold until next year when I will hopefully have the time to investigate what’s happening there. Until then, have a look at a very nice backup plugin called http://backwpup.com – it does everything that Snapshot Backup does and more. It’s free and it’s in active development. Hopefully this will alleviate your issues.

Change the command from ‘tar -cvf’ to ‘tar -cvzf’ (it’s just an additional letter) and gzip I used.

I know it’s not a very convenient method, but I’m currently not planning any updates until I can find the time to completely rewrite the plugin from scratch. If you’re interested in something a lot slicker and with a lot more options, check out http://backwpup.com (it also supports gzip).