Created
May 5, 2020 17:57
-
-
Save kolosek/e4109e6d2d588f9ae90aff1e4f0cb925 to your computer and use it in GitHub Desktop.
Script for making automatic dumps of postgres database sorted by date
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 | |
| DIR=/home/httpd/DIR_LOCATION; | |
| DB=(DATABASE_NAME); | |
| DATE=$(/bin/date '+%Y%m%d'); | |
| TENDAY=$(/bin/date -d'10 days ago' '+%Y%m%d'); | |
| /bin/mkdir -p $DIR/$DATE/; | |
| for d in "${DB[@]}" | |
| do | |
| pg_dump -f $DIR/$DATE/$d.sql $d; | |
| gzip -f $DIR/$DATE/$d.sql; | |
| aws s3 cp $DIR/$DATE/$d.sql.gz s3://DIR_ON_S3/$DATE/ | |
| done | |
| rm -rf $DIR/$TENDAY/; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment