Skip to content

Instantly share code, notes, and snippets.

@kelby
Forked from skyebook/backup_postgres.sh
Last active October 29, 2015 04:41
Show Gist options
  • Save kelby/eb31abcb25594bcc285d to your computer and use it in GitHub Desktop.
Save kelby/eb31abcb25594bcc285d to your computer and use it in GitHub Desktop.
Backup OpenShift PostgreSQL Database
#!/bin/bash
# Backs up the OpenShift PostgreSQL database for this application
# by Skye Book <[email protected]>
# Local
rhc ssh
# Seiver
NOW="$(date +"%Y-%m-%d")"
FILENAME="$OPENSHIFT_DATA_DIR/$OPENSHIFT_APP_NAME.$NOW.backup.sql.gz"
pg_dump $OPENSHIFT_APP_NAME | gzip > $FILENAME
# Local
echo $FILENAME
rhc scp rails4app download /tmp $FILENAME
gunzip # $OPENSHIFT_APP_NAME.$NOW.backup.sql.gz
psql databasename < data_base_dump
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment