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
  1. Greg Linch

    I’ve thought a lot about how Flashbake — or, more broadly, the concept behind that software — could help simplify pushing writing to GitHub. Here it is on Github:

    More on Flashbake:

    So, here’s an idea married to yours:

    I use PlainText, which syncs with Dropbox, as my primary mobile note-taking app. I use it on my iPhone, iPad and MacBook Pro while online and offline. You could set the directory Flashbake uses as same one you use for the Dropbox directory with Plaintext. Then you hook it into the Github integration tool you propose for pushing to/from WordPress.

    This trifecta might be too much, but I’m not aware of a better way to handle simple, offline text editing in this realm. Anywho, just a thought.

    Also, check out

  2. Max

    Interesting thoughts, Greg. I hadn’t heard of Flashbake, but it looks pretty interesting.

    There exist a number of plugins that’ll backup WordPress to Dropbox or S3, but I haven’t seen any that do the reverse. That could also be a worthwhile plug-in idea, and most likely much easier than this one to implement.

    For (online) blog posting on the go, I’d recommend using one of the WordPress mobile apps. Offline support is still pending on most (all?) of the apps, but you should voice your support for such features to convince Automattic to add them faster.

  3. Jason

    I’d like to manage WordPress with Git, too. Have you seen this?

    GitPublish: “Python framework for using git push / pull metaphor for synching content to remote doc containers e.g. wordpress…”

  4. Max

    @Jason: No, I had not seen that, though it looks pretty interesting. I’ll certainly take a deeper look at it before I try to build anything myself, and I’ll post some thoughts if/when that happens.

Leave a Reply