-
-
Save sethbergman/3f5a74d127d557f791cd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /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 -type d -mtime +10) | |
if [ -n "$OLD" ] ; then | |
echo deleting old backup files: $OLD | |
echo $OLD | xargs rm -rfv | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment