Skip to content

Instantly share code, notes, and snippets.

@izaac
Forked from shaiton/backup_postgres.sh
Last active August 29, 2015 14:13
Show Gist options
  • Save izaac/442aacc2177c187fa788 to your computer and use it in GitHub Desktop.
Save izaac/442aacc2177c187fa788 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Backs up the OpenShift PostgreSQL database for this application
# by Skye Book <[email protected]>
NOW="$(date +"%Y-%m-%d")"
FILENAME="$OPENSHIFT_DATA_DIR/$OPENSHIFT_APP_NAME.$NOW.backup.sql.gz"
find $OPENSHIFT_DATA_DIR -name $OPENSHIFT_APP_NAME.*backup* -type f -mtime +30 -exec rm '{}' \;
pg_dump $OPENSHIFT_APP_NAME | gzip > $FILENAME
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment