Idea: Git backup of WordPress blog

I learned a long time ago the value of backing up the important data on my computers. Using various tools, most of my files are backed up automagically, without any manual work as I go about my day-to-day business.

I’ve long wanted a similarly awesome way to back up my website/blog, without manually exporting the database and rsyncing the files. VaultPress sounds wonderful, but would cost more than actually hosting the site in the first place. A potential solution: save all site content in version control, including both database objects and files-on-disk.

Some of my friends have turned to static sites using tools like Jekyll or by manually maintaining HTML files. This allows them to keep everything in source control and also keeps hosting costs super-low (using services like S3 instead of a full LAMP server).

I almost went that route, but I decided to keep using WordPress. I’m a firm believer in dogfooding, and I didn’t want to be contributing to WordPress-related projects and not actually be using the software in a “production” environment. I’m disappointed that many WordPress core devs/contributors don’t really use their own WordPress blogs, but that’s a topic for another day.

(Note: what follows is only a partially-baked idea.)

WordPress has a “revisions” system built-in, but does not (yet) have a particularly good interface for managing or viewing that history. What’s really good at managing history and versions of primarily textual content? Version control systems, such as Git or SVN.

I’d like to see is a plug-in that mirrors your WordPress content to a git repository (e.g., GitHub). A poor-man’s VaultPress, if you will (minus VaultPress’ security component).

Preliminary design would be to have a folder for each content type (posts, pages, comments, links, media, each custom post type, etc.), and within those folders would be one file per object of that type. When you save, e.g., a post in the WordPress admin, the plug-in commits a new version of the corresponding file in the git repository.

This would allow for real-time backup of most content saved to the WordPress database. To restore the content, you’d have a few options: “play back” the commit log, take the latest revision of each file, or generate a full WXR file.

I see this eventually being bidirectional (write posts in text editor, commit to Git, have it automatically pushed to WordPress), and perhaps even support forking for collaborative writing (see Greg’s post).

I don’t have the bandwidth to work on this at the moment, but if someone else wants to take a stab at it, I’d be super grateful. Otherwise, it’s on my work queue and I may try to have it ready for a potential lightning-talk at WordCamp Philly in early November.

 

4 Responses to Idea: Git backup of WordPress blog

Leave a Reply