• OpenShift PostgreSQL Backups

    Over the last few months I’ve been testing Red Hat’s new PaaS offering, OpenShift.  The testing insofar has gone extremely smooth, but what about preparing for when disaster strikes.  The rhc command-line client provides snapshot functionality but unfortunately carries the caveat of needing to shut down and restart the application in the process.  For a PHP or Python application this is fine as restarts are lightning fast, but redeploying a JavaEE application is… cough… not so lightning fast.

    If you can live with the need to restart, this command will give you a very complete tarball:

    rhc app snapshot save -a ApplicationName

    The other option is to do it via a cron job that will back up the data into your OpenShift data directory on the server (the data in this directory is not deleted each time the application is redeployed).  To do this, you will need to have the cron cartridge installed in your application.

    If you don’t already have the cron cartridge installed, you can easily enable it with this command:

    rhc app cartridge add -a ApplicationName -c cron-1.4

    With cron setup, we can setup jobs to run minutely, hourly, daily, weekly, or monthly by dropping scripts into the appropriate folder in our application’s .openshift/cron directory. Create a file named backup_postgres.sh in the minutely, hourly, daily, weekly, or monthly folder and paste the following script in. (Also available on GitHub)

    #!/bin/bash
    # Backs up the OpenShift PostgreSQL database for this application
    # by Skye Book <skye at skyebook.net>
    
    NOW="$(date +"%Y-%m-%d")"
    FILENAME="$OPENSHIFT_DATA_DIR/$OPENSHIFT_APP_NAME.$NOW.backup.sql.gz"
    pg_dump $OPENSHIFT_APP_NAME | gzip &gt; $FILENAME

    With the backup script created simply commit it and push the changes to your application.

    git add backup_postgres.sh
    git commit -m "Added PostgreSQL backup script"
    git push

    Once the changes are pushed you can retrieve your application’s database backups by using rsync

    rsync -avz -e ssh loginhash@appname-you.rhcloud.com:app-root/data ./

    This, admittedly, isn’t the prettiest solution to the problem but it does its job.  I may end up patching the rhc CLI app to do something similar to this and automatically download the results.

  • Finally a Real Website

    Well its only taken [insert unforgivable number of years], but I’ve finally gotten myself a serviceable web page at the root of my domain..  I still need to finish adding all of the content but I’m glad to have something up with at least some color instead of just redirecting to this rather drab (but very smart and full of knowledge!) blog.

    That said, I’ll see you over at https://skyebook.net

  • Where Have I Been?

    I realize I’ve been more vacant than usual these last few months, perhaps its time to get a post down on [roughly] what I’ve been up to.  In late February I took on a pretty interesting job for a big name client (details coming soon!).  The work has afforded me the ability to become quite intimate with a number of technologies of which I’d only had “user manual” level experience.

    • Event Driven HTTP Servers in Java
    • Lots of spatial analysis using PostgreSQL’s built-in Geometry types (I didn’t even know these existed outside of PostGIS)
    • Circle Packing algorithms
    • Super Bonus:Processing found its way back into my life!  Visual prototypes that happened to be beautiful really helped me out.

    There will be more information about what I’m up to in a the next week or two, but its exciting and I’m working with some awesome people.. Stay tuned!

  • Site Back Up

    After participating in Move Your Domain Day and moving a number of domains under my control from GoDaddy to Gandi, my site experienced some down time as their way of setting DNS records up was a little strange.  The fact that I was editing my records at all was a bit strange as Gandi seemed to indicate that it would copy my pre-existing zone file, but it is what it is.  That said, we’re back up and running.  Cheers.

  • I Now Have an M.S Degree!

    I should have posted this when it actually happened, but its been a busy few weeks.  My thesis defense, unfortunately, got bumped up to December 16th, giving me fewer days to rehearse the presentation and get all my ducks in a neatly aligned row.  That said, I defended successfully and now have an M.S in Integrated Digital Media from the Polytechnic Institute of NYU.  Cool!  I was lucky enough to have a great panel for the defense who were able to really push me on a topic they all knew pretty well.  It was a lot of [nerve-wracking] fun!  My thanks to Carl Skelton (NYU-Poly), Susan Gladstone (NYU-Poly), Dororthy Nash (NYC Office of Emergency Management), and Frank Hebbert (OpenPlans) for their participation and feedback.

     

    The topic, which you might remember, has morphed from 3D visualization of geodata to an argument for open geodata is ongoing for me and revisions to the paper are ongoing.