Last active
January 19, 2018 09:10
-
-
Save numb95/8e4ce3118743e23c6c43ac83d2fd5af5 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 | |
# Daily Backup | |
#You can add script to Cron | |
BACKUP_DIR=/home/conf/backup/db | |
DAYS_TO_KEEP=30 | |
PROJECT_NAME=project | |
FILE_SUFFIX=_pg_backup.sql | |
DATABASE= | |
USER=postgres | |
FILE=`date +"%Y%m%d%H%M"`${PROJECT_NAME}${FILE_SUFFIX} | |
OUTPUT_FILE=${BACKUP_DIR}/${FILE} | |
pg_dump -U ${USER} ${DATABASE} -F p -f ${OUTPUT_FILE} | |
gzip $OUTPUT_FILE | |
find $BACKUP_DIR -maxdepth 1 -mtime +$DAYS_TO_KEEP -name "*${FILE_SUFFIX}.gz" -exec rm -rf '{}' ';' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment