Setting up a periodic PostgreSQL DB dump

  1. Add cron cartridge

    In order to run periodic tasks, be sure to add the cron cartridge to your app:

    rhc cartridge add cron-1.4 -a <app_name>

    Note: you currently can’t add the cron cartridge to scaled apps

  2. Download and copy s3cmd to your OpenShift data folder

    Download s3cmd from, copy it to OpenShift and unpack it:

    scp s3cmd-1.5.0-alpha3.tar.gz openshiftusername@address:app-root/data
    rhc ssh <app_name>
    cd app-root/data
    tar xzvf s3cmd-1.5.0-alpha3.tar.gz
    rm s3cmd-1.5.0-alpha3.tar.gz
    mv s3cmd-1.5.0-alpha3 s3cmd
    cd s3cmd

    Now run the following command and put in your Amazon S3 secret keys:

    s3cmd --configure -c .s3cfg
  3. Set up cron script

    Add the following code to your 9.openshift/cron/daily folder (or hourly if you want more frequent backups):

    # Backs up the OpenShift PostgreSQL database for this application
    # by Skye Book <>
    NOW="$(date +"%Y-%m-%d")"
    cd $OPENSHIFT_DATA_DIR/s3cmd
    s3cmd -c .s3cfg put $FILENAME s3://mediathreadbackups