A better way to back up WordPress on OpenShift

My first post on backing up WordPress on OpenShift, was something of a hack-job. Git-clone and MySQL dump — it does the trick, and your blog won’t even see any down time, but it’s messy.

Mateus Caruccio of Getup Cloud suggested a much more elegant solution, that I only could have missed from an appalling lack of RTFMing.

[jason@localhost ~]$ mkdir blog
[jason@localhost blog]$ rhc snapshot-save -a blog
Pulling down a snapshot to blog.tar.gz...
Creating and sending tar.gz


Ok, cool. Let’s check out what it pulled down.

[jason@localhost blog]$ tar xvz blog.tar.gz
[jason@localhost blog]$ ls
[jason@localhost blog]$ cd 51b4c584500446eb79000070
[jason@localhost 51b4c584500446eb79000070]$ ls
app-deployments  app-root  git  mysql  php

Interesting. So it just pulled down the gear directory from /var/lib/openshift on its hosting node. Just to verify:

[jason@localhost 51b4c584500446eb79000070]$ rhc ssh blog
Connecting to 51b4c584500446eb79000070@blog-callaway.rhcloud.com ...


    You are accessing a service that is for use only by authorized users.  
    If you do not have authorization, discontinue use at once. 
    Any use of the services is subject to the applicable terms of the 
    agreement which can be found at: 


    Welcome to OpenShift shell

    This shell will assist you in managing OpenShift applications.

    Shell access is quite powerful and it is possible for you to
    accidentally damage your application.  Proceed with care!
    If worse comes to worst, destroy your application with "rhc app delete"
    and recreate it

    Type "help" for more info.

[blog-callaway.rhcloud.com 51b4c584500446eb79000070]> ls
app-deployments  app-root  git	mysql  php

But it’s not quite the same.

[blog-callaway.rhcloud.com 51b4c584500446eb79000070]> find . | wc -l
find: `./.ssh': Permission denied
find: `./.sandbox': Permission denied
find: `./.tmp': Permission denied
[blog-callaway.rhcloud.com 51b4c584500446eb79000070]> exit
Connection to blog-callaway.rhcloud.com closed.
[jason@localhost 51b4c584500446eb79000070]$ find . | wc -l

This could be fun to dig into later. Still, that explains why the gear had to be shut down — look:

[jason@localhost 51b4c584500446eb79000070]$ ls mysql/data/blog/
db.opt              wp_postmeta.frm            wp_terms.MYD
wp_commentmeta.frm  wp_postmeta.MYD            wp_terms.MYI
wp_commentmeta.MYD  wp_postmeta.MYI            wp_term_taxonomy.frm
wp_commentmeta.MYI  wp_posts.frm               wp_term_taxonomy.MYD
wp_comments.frm     wp_posts.MYD               wp_term_taxonomy.MYI
wp_comments.MYD     wp_posts.MYI               wp_usermeta.frm
wp_comments.MYI     wp_snippets.frm            wp_usermeta.MYD
wp_links.frm        wp_snippets.MYD            wp_usermeta.MYI
wp_links.MYD        wp_snippets.MYI            wp_users.frm
wp_links.MYI        wp_term_relationships.frm  wp_users.MYD
wp_options.frm      wp_term_relationships.MYD  wp_users.MYI
wp_options.MYD      wp_term_relationships.MYI
wp_options.MYI      wp_terms.frm

All of the MySQL data files are there. It didn’t do a dump, it grabbed the whole filesystem, which was cool because the database was shut down. And that’s one downside. If you try to access your blog while it’s snapshotting, you’ll get:

Service Temporarily Unavailable

The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.
Apache/2.2.22 (Red Hat Enterprise Web Server) Server at blog.jasoncallaway.com Port 80

So if that matters to you, the messy approach from my previous post is an alternative. But in ease-of-use terms, rhc snapshot is far superior. You can also restore with the same interface via rhc snapshot-restore.


3 thoughts on “A better way to back up WordPress on OpenShift

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s