Skip to content

Instantly share code, notes, and snippets.

@henrik
Last active November 25, 2018 18:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save henrik/1043fecdd0937034cd62 to your computer and use it in GitHub Desktop.
Save henrik/1043fecdd0937034cd62 to your computer and use it in GitHub Desktop.
For `Flink/dokku-psql-single-container`. See https://gist.github.com/henrik/26bb73091712aa42abf2#db-backups
#! /bin/bash
# For use with Flink/dokku-psql-single-container.
# Based on http://donpottinger.net/blog/2014/11/25/postgres-backups-with-dokku.html
set -e
BASE_DIR="/var/backups/postgres"
mkdir -p $BASE_DIR
YMD=$(date "+%Y-%m-%d")
FILE="$BASE_DIR/$YMD.dump"
/usr/bin/docker exec psql-single-container su postgres -c "pg_dumpall" > "$FILE"
# delete backup files older than 10 days
# (since Digital Ocean disk backups can be as infrequent as every 7 days)
OLD=$(find $BASE_DIR -mtime +10)
if [ -n "$OLD" ] ; then
echo deleting old backup files: $OLD
echo $OLD | xargs rm -rfv
fi
@henrik
Copy link
Author

henrik commented Sep 2, 2015

Also see Flink/dokku-psql-single-container#17 (comment) which gets all DBs but as separate dumps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment