-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1272 from SEED-platform/v2.0.1
Merge 2.0.1 release branch
- Loading branch information
Showing
94 changed files
with
4,511 additions
and
2,797 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/bin/bash | ||
|
||
# Nightly backups - crontab | ||
# 0 0 * * * /home/ubuntu/prj/seed/bin/backup_database.sh <db_name> <db_username> <db_password> | ||
|
||
DB_NAME=$1 | ||
DB_USERNAME=$2 | ||
# Set PGPASSWORD as pg_dump uses this env var. | ||
DB_PASSWORD=$3 | ||
|
||
function file_name(){ | ||
echo ${BACKUP_DIR}/${DB_NAME}_$(date '+%Y%m%d_%H%M%S').dump | ||
} | ||
|
||
if [[ (-z ${DB_NAME}) || (-z ${DB_USERNAME}) || (-z ${DB_PASSWORD}) ]] ; then | ||
echo "Expecting command to be of form ./backup_database.sh <db_name> <db_username> <db_password>" | ||
exit 1 | ||
fi | ||
|
||
# currently the backup directory is hard coded | ||
BACKUP_DIR=~/seed-backups | ||
mkdir -p ${BACKUP_DIR} | ||
|
||
export PGPASSWORD=${DB_PASSWORD} | ||
echo "pg_dump -U ${DB_USERNAME} -Fc ${DB_NAME} > $(file_name)" | ||
pg_dump -U ${DB_USERNAME} -Fc ${DB_NAME} > $(file_name) | ||
unset PGPASSWORD | ||
|
||
# Delete files older than 30 days | ||
find ${BACKUP_DIR} -mtime +30 -type f -name '*.sql' -delete |
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
This file was deleted.
Oops, something went wrong.
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
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
Oops, something went wrong.