Gaurav Mantri's Personal Blog.

Backup WordPress Site to Windows Azure Storage using “BackupToAzure” Plugin

It gives me great pleasure to announce “BackupToAzure” plugin for WordPress. This plugin will allow you to take a full backup of your existing WordPress site to Windows Azure Storage. The plugin is free and is open source!!!

Download the plugin from WordPress Plugin Directory: http://wordpress.org/plugins/backuptoazure/

 

History

Like millions of other sites, this site is also running on WordPress. Puneet of IdeaBox Creations helped me set up this blog. One fine evening I was having a conversation with him about how I could take a backup of my blog and he recommended that I could either Amazon S3 or DropBox for that purpose (apart from the backup my hosting company provided). Given my love for Windows Azure Smile, it bothered me that while I could take a backup of my blog to Amazon and DropBox I could not take a backup to Windows Azure. There were few other things I noticed with other backup plugins:

  • Some of them only took the backup of the “wp-content” directory and did not touch MySQL database at all.
  • Some which took the backup of the database, the backup process involved copying the database file as is.

So I discussed this idea about building a WordPress backup plugin which will actually backup my blog to Windows Azure with Puneet and few other folks. There were a few other things I wanted:

  • Instead of just dumping the database file in storage, I wanted to take a record-by-record backup.
  • The plugin should support both full backup and incremental backup i.e. only take a backup of modified records (this is still not done BTW)
  • (A mighty or pipedream Smile) I would have liked to run the WordPress site completely off of Windows Azure Storage instead of using MySQL database.

The problem was “I didn’t know PHP” and unfortunately I did not have enough time to learn PHP. So I put this idea on the backburner at that time. However the thought of having this kind of plugin kept bothering me.

Then I was approached by a few students from my alma mater, NIT Jaipur (it was called MREC Jaipur when I graduated). They wanted to do summer internship with me and when I presented this idea to them, they jumped on it! In a matter of months, they produced this plugin which I extremely proud to present today in this post.

Team

Let’s first meet the team responsible for the development of this product. Without them, this would have been another one of my “unfulfilled wacky” idea Smile.

Prateek Soni

Prateek Soni
Prateek is a final year student at MNIT Jaipur . His interest towards a creative and useful application development has always been above anything else. The technologies he is currently working on are Windows Azure Storage (via PHP), WordPress Plugin Development (via PHP) and MYSQL. He is available on Facebook || LinkedIn || Email: prateeksoni7529 at gmail.com.

Pawan Soni

Pawan SoniPawan is a final year student at MNIT Jaipur. His interested areas of computer science are computer networking & Application development. He is currently working on a project based on WordPress plugin development & Windows Azure Storage (PHP SDK ) and MySQL. He is available on Facebook || LinkedIn || Email: soni.pawan85 at gmail.com.

Mohit Banka

Mohit BankaMohit is a final year undergrad at MNIT Jaipur. His interest lies mainly in the field of Cloud Security, Neural networks, Steganography and Artificial Intelligence. He likes travelling and spends his leisure time playing snooker and table tennis. He is available on LinkedIn || Email: mohitbanka532 at gmail.com.

Kuldeep Sharma

Kuldeep SharmaKuldeep is final year undergrad at MNIT Jaipur. His interests fall mainly in the field of Big Data technology, Cloud and Machine Learning. He is also a Web/Desktop application developer who specializes in back-end development. On his free time he likes to play badminton and Counter Strike. He is available on LinkedIn || Email: kuldeep.mnit at outlook.com.

Samarth Sikand

Samarth SikandSamarth is final year undergrad at LNMIIT Jaipur. He has interests in the field of Cloud Computing, Operating Systems and Web Designing. He is a movie buff and likes to play badminton. He is available on LinkedIn || Email: sikandsamarth at yahoo.com.

I was completely surprised by their technical acumen and thought process considering they are just students. I had some really crazy ideas about how this should work which was really convoluted and technically impossible to do and they came up with a really elegant solution for this whole thing.

Hint Hint: If you’re planning on hiring for your startup, you may want to talk to them Smile.

Features

Now let’s talk about the features. Following are some of the features available in the plugin as of today:

  • Supports full backup of any WordPress installation. Partial or incremental backups are still not supported but it’s in the product pipeline.
  • MySQL tables are backed up in Windows Azure Table Storage so that you have a row-by-row backup.
  • Content is backed up in Windows Azure Blob Storage. Currently the plugin copies all files in the “wp-content” directory in blob storage.
  • To circumvent 64 KB size limit per attribute, all big data types (like TEXT etc.) are stored in blob storage with a link to the blob in table storage.

How to Get It

You can download/install plugin from WordPress Plugin Directory: http://wordpress.org/plugins/backuptoazure/. The source code of the plugin is available on Github (Yes, its open source Smile) . The link for the Github repository is: https://github.com/backuptoazure/Backup-Plugin. Feel free to browse through code and play with it.

What You Need

PHP version 5.3.1 or greater and WordPress 3.2 or greater and a Windows Azure Storage Account (duh!!!) Smile

How to Use It

Step 1

Install this plugin like any other WordPress plugin or you can use FTP to upload it directly to Plugin’s folder of your web directory.

Step 2

After activating the plugin you will find a “Backup To Azure” tab on the left side menu on the dashboard.

clip_image002

Step 3

On that tab you need to enter your Windows Azure Storage credentials. Please note that the plugin doesn’t store these credentials. It passes them from one page to another using HTML POST method. Since the plugin passes the parameters through HTTP POST, it is possible that somebody may intercept the traffic between your browser and WordPress site. It is recommended that either you make use of SSL or change the account key after one backup operation is complete.

Step 4

Once your credential are verified you can see the logs of your previous backup. You may choose to delete any or all of them.

clip_image004

Step 5

To start a new backup, just click on “Start New Backup” button. On clicking “Start New Backup” the backup schedule will start running it will first take database backup and then content backup.

clip_image006

clip_image008

How It Works – Technical Mumbo Jumbo Smile

Now let’s see how this Plugin has been implemented Smile

Storage Credentials Validation

To validate the credentials, the plugin creates a random table (a 30 character random string) and check for the response message. If response is 303 or 403, then it is assumed that the credentials are invalid. If they are valid then the logs are displayed where old backups can be deleted and new backups can be created. In future version, this implementation would be changed. In future version, instead of creating a random table the plugin will try to fetch just one table from the storage and check for response.

Database Backup

The main aim was to keep things dynamic i.e. not to use any static information about database. The reason for this is to make this plugin failsafe from database schema changes. To accomplish this, the plugin uses 3 type of queries:

1. Show table: To get table names in the database.

2. Describe table: To get table’s schema and

3. Select query: To get table’s data.

Once the schema for a table and data is fetched, the plugin creates entities and upload them to table storage.

As mentioned above, the table could contain large text and even binary data which may not fit in 64 KB attribute size limit. For all of these column types, the plugin actually stores the column content in blob storage and stores the blob URL in table storage.

At this time, all MySQL tables get backed up in a single Windows Azure Table or in other words for each backup this plugin creates a single table. The name of the table will be in the following format: {MySQL DatabaseName}_{BackupDateTime}. The reason it is being done was to take full advantage of NoSQL and Schemaless nature of Windows Azure Table Storage. For each entity, the PartitionKey for each entity would be the name of MySQL database table and the RowKey is the primary key column value.

Content Backup

As mentioned above, the plugin takes a backup of “wp-content” folder of WordPress installation. To create a content backup, the plugin recursively goes through that folder and opens every file in “read” mode (so that you can feel safe about your data J). Then each file is uploaded in blob storage.

Future Enhancements

This is just the first version of this plugin. Depending on the success of this release and the availability of the team (as they are students who have a busy final year and corporate life ahead of them), there are many things in the pipeline. Some of them are:

  • Support for incremental backups.
  • Support for backup scheduling so that the backup process runs without manual intervention.
  • Restore from backup.
  • (My personal pipe dream Smile) Run WordPress off of Windows Azure Storage!

Humble Request

This was done by students in a very short amount of time so the code may not be of that great quality so please bear with it. At the same time, please do provide feedback to them (good, bad, ugly Smile). If you really liked the plugin, please-please don’t hesitate to encourage them. Who knows, your encouragement might make them consider taking this project on a full time basis and turn them into entrepreneurs!!! They have set up a dedicated email for this project (backuptoazure@gmail.com) so please it is my humble request to send them feedback. I would really appreciate that.

Summary

Nothing much to say except give it a try! I think it’s really useful considering there are so many WordPress sites and Windows Azure Storage provides a cheap storage solution.


[This is the latest product I'm working on]