WordPress Backups

dropbox_logo

This might seem like a pretty boring subject for a post, but if you spend time on the internet (we all do!) then you may have noticed that the WordPress platform is getting more and more popular. It uses templates for general look and feel, widgets to extend capabilities and an SQL database backend to store content. It all works awesomely well, and you don’t have to know anything about HTML, CSS or other arcane arts. This site is a WordPress site.

The problem comes with backups. In general we require a backup to be

1. Automatically triggered
2. Off site
3. Backup stored in multiple places
4. Multiple versions of each backup
5. Notification of backups
6. Complete so you can do a full restore

I’ve investigated several WordPress backup solutions and they’ve all been difficult to set up, or miss the boat for one or more of the other critical requirements. Enter BackWPup. When you install this free plugin, it requests access to your Dropbox, you set the backup schedule, what you’d like to back up, where you’d like it stored- and that’s it! It supports a whole bunch of target destinations for your backup including Dropbox, Sugarsync, Amazon, Google etc. It still leaves a few unanswered questions though, so let’s go through them one at a time.

1. Automatically triggered. Yes, it utilises the cron feature on your host. In shared hosting (like I have) there is a caveat that due to limited resources your backup may get interrupted, but will still complete. I have witnessed this.
2. Off site. My website is stored in a data centre in Sydney, Dropbox is stored in Amazon’s S3 cloud. Tick!
3. Backup stored in multiple places. I have Dropbox installed on my desktop computer which is automatically synced with the cloud. Nice
4. Multiple versions of each backup. Yes, they are named and stored according to rules you can set

5. Notification of backups. This, again, is handled nicely by the plugin. I noticed that the developer of another plugin I tried provides the plugin for free but then has several upsell opportunities after installation. One of these is an email notifier ($9 per year) for when a backup is complete- but hang on- doesn’t Dropbox have a notifier? Well yes, but it uses the Growl system, meaning that if you backup when you should (at night) you won’t sees the notifications unless you are a vampire. Surely there is a better way? Possibly. It was here that I realised we might get some love from If This Then That (IFTTT). This is a website that allows you to hook into lots of websites and automate things to happen. This means I can get it hooked up to Dropbox, and tell it that when new files appear, send me an email. Cool! As an aside, there are bunches of other ‘recipes’ (scripts) available on the site, from the mundane ‘ Twitter update when I publish a new blog post’ to the creepy ‘every time I’m tagged in a Facebook photo, download the photo to my Google Drive’ and practical ’email me whenever a new book is added to the top 100 free book list’. I already think I’m in love with this website. A note about the $9 cost of the email notifier- if it was $9 to purchase once only I probably would have done that, but I try very hard to minimise the number of subscription type services that I buy. I’m not opposed to people selling things this way, I just find it hard to manage all these little items.

6. Complete so you can do a full restore. Another tick, but this will need to be tested. I’ll set up WordPress on my Synology NAS and try a restore to that.

 backwpupbanner2

During all of this testing I found that none of the backup plugins would work for backups over about 10mb in size. Meaning they were essentially useless as my websites are 1-200mb in size. The web host was not interested because it’s a 3rd party product. After a public appeal they did put someone on the job, who discovered the issue was an incompatibility with the web server software they are using. They use Litespeed instead of Apache. They got Litespeed involved, and developed a fix that revolves around adding some code to your .htaccess file to prevent Litespeed from killing your script. Here are the instructions for the fix

 

Log in to your cpanel
go to ‘File Manager’
make sure ‘show dotfiles (hidden files) is turned on
go to your ‘public_html’ folder
open your ‘.htaccess’ file with an editor

add the line
RewriteRule ^$ – [E=noabort:1]
Then at the bottom, add

# END WordPress

<IfModule litespeed>
RewriteRule .* – [E=noabort:1]
</IfModule>

or you can add the more complex, but tidier solution
RewriteRule /home/youraccount/public_html/pathtophpscript – [E=noabort:1]
which is slightly better because it does not allow other scripts to run wild
your .htaccess file should look something like this-
 _______________________________________________

# Inserted By Customer Control Panel
SetEnv PHPRC /home/yourdomain/public_html

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^$ – [E=noabort:1]
RewriteRule ^index\.php$ – [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

<IfModule litespeed>
RewriteRule .* – [E=noabort:1]
</IfModule>

 _______________________________________________

 

Permissions on this file should be 0644 or possibly 0755 if you check WordPress codex. I have verified that this fix does appear to work. I’ve had minor problems with backups since, but tweaking the options seems to allow the backups to work reliably and well.
Adam is a 20+ year veteran of the Apple market. He is one of the most highly qualified Apple technical specialists in Australia. You can read more about him here or check out his Google+ profile- Adam Connor