Last active
          November 25, 2018 18:09 
        
      - 
      
- 
        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
  
        
  
    
      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 -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
  
            
Also see Flink/dokku-psql-single-container#17 (comment) which gets all DBs but as separate dumps.