Skip to content

Instantly share code, notes, and snippets.

@shaiton
Forked from skyebook/backup_postgres.sh
Last active November 29, 2015 09:51
Show Gist options
  • Save shaiton/e505608c0b3bc9bc5aac to your computer and use it in GitHub Desktop.
Save shaiton/e505608c0b3bc9bc5aac 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