-
-
Save dumbbond/a4e1a3387f10c666fb55bbe8fe394ecf 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 | |
| # directory to save backups in, must be rwx by postgres user | |
| BASE_DIR="/var/backups/postgres" | |
| YMD=$(date "+%Y-%m-%d") | |
| DIR="$BASE_DIR/$YMD" | |
| mkdir -p $DIR | |
| cd $DIR | |
| # make database backup | |
| dokku postgresql:dump sport | gzip -9 > "$DIR/db.out.gz" | |
| # delete backup files older than 7 days | |
| OLD=$(find $BASE_DIR -type d -mtime +7) | |
| 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