For use with Flink/dokku-psql-single-container.

December 18, 2016 ยท View on GitHub

#! /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"+FILE="(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(find BASE_DIR -mtime +10) if [ -n "OLD"];thenechodeletingoldbackupfiles:OLD" ] ; then echo deleting old backup files: OLD echo $OLD | xargs rm -rfv fi