mirror of
https://github.com/cookiecutter/cookiecutter-django.git
synced 2025-08-18 02:44:51 +03:00
mysql local backup script updated
This commit is contained in:
parent
e466817cae
commit
8091fc4004
|
@ -4,7 +4,7 @@
|
|||
### Create a database backup.
|
||||
###
|
||||
### Usage:
|
||||
### $ docker-compose -f <environment>.yml (exec |run --rm) postgres backup
|
||||
### $ docker-compose -f <environment>.yml (exec |run --rm) mysql backup
|
||||
|
||||
|
||||
set -o errexit
|
||||
|
@ -17,22 +17,23 @@ source "${working_dir}/_sourced/constants.sh"
|
|||
source "${working_dir}/_sourced/messages.sh"
|
||||
|
||||
|
||||
message_welcome "Backing up the '${POSTGRES_DB}' database..."
|
||||
message_welcome "Backing up the '${MYSQL_DATABASE}' database..."
|
||||
|
||||
|
||||
if [[ "${POSTGRES_USER}" == "postgres" ]]; then
|
||||
message_error "Backing up as 'postgres' user is not supported. Assign 'POSTGRES_USER' env with another one and try again."
|
||||
if [[ "${MYSQL_USER}" == "root" ]]; then
|
||||
message_error "Backing up as 'root' user is not supported. Assign 'MYSQL_USER' env with another one and try again."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
export PGHOST="${POSTGRES_HOST}"
|
||||
export PGPORT="${POSTGRES_PORT}"
|
||||
export PGUSER="${POSTGRES_USER}"
|
||||
export PGPASSWORD="${POSTGRES_PASSWORD}"
|
||||
export PGDATABASE="${POSTGRES_DB}"
|
||||
export MYSQL_TCP_PORT="${MYQL_PORT}"
|
||||
export MYSQL_HOST="${MYSQL_HOST}"
|
||||
|
||||
backup_filename="${BACKUP_FILE_PREFIX}_$(date +'%Y_%m_%dT%H_%M_%S').sql.gz"
|
||||
pg_dump | gzip > "${BACKUP_DIR_PATH}/${backup_filename}"
|
||||
backup_file_path="${BACKUP_DIR_PATH}/${backup_filename}"
|
||||
|
||||
|
||||
message_success "'${POSTGRES_DB}' database backup '${backup_filename}' has been created and placed in '${BACKUP_DIR_PATH}'."
|
||||
mysqldump --user=${MYSQL_USER} --password=${MYSQL_PASSWORD} --port=${MYSQL_PORT} ${MYSQL_DATABASE} | gzip > "${backup_file_path}"
|
||||
|
||||
|
||||
|
||||
message_success "'${MYSQL_DATABASE}' database backup '${backup_filename}' has been created and placed in '${BACKUP_DIR_PATH}'."
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
### View backups.
|
||||
###
|
||||
### Usage:
|
||||
### $ docker-compose -f <environment>.yml (exec |run --rm) postgres backups
|
||||
### $ docker-compose -f <environment>.yml (exec |run --rm) mysql backups
|
||||
|
||||
|
||||
set -o errexit
|
||||
|
|
Loading…
Reference in New Issue
Block a user