Created
December 7, 2021 16:14
-
-
Save SherazKhan/021a2502375ff4be8892e521d29b76da to your computer and use it in GitHub Desktop.
This file contains 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/sh | |
# PostgreSQL database backup script | |
DB_USERNAME='' | |
DB_NAME='' | |
DB_PASSWORD='' | |
DB_HOST='' | |
TIMESTAMP=`date +%Y%m%d-%H%M` | |
BACKUP_DIR='/Vast/pg_backup' | |
FILENAME=$TIMESTAMP.sql.gz | |
pg_dump postgres://$DB_USERNAME:$DB_PASSWORD@$DB_HOST/$DB_NAME | gzip > $BACKUP_DIR/$FILENAME \ | |
&& find $BACKUP_DIR -name '*.gz' -mtime +14 -print0 | xargs -0 rm -f |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment