From 72782585be08fe08f0e299ab5ffb22c4f6615f5e Mon Sep 17 00:00:00 2001 From: Ari Timonen Date: Thu, 9 Apr 2020 04:21:50 +0300 Subject: [PATCH] Update migrations to entry.sh and and dump script --- INSTALL.md | 2 ++ bin/script/entry.sh | 2 +- script/dump_db.sh | 6 ++++++ 3 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 script/dump_db.sh diff --git a/INSTALL.md b/INSTALL.md index 1fa44ae..29648ae 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -27,6 +27,8 @@ Install git: https://git-scm.com/book/en/v2/Getting-Started-Installing-Git ## 4. Put any database dumps to `db/initdb.d`. (optional) +You can use `script/db_dump.sh` to dump production database. + mysqldump --opt -h DATABASE_IP -u USERNAME DATABASE_NAME > 00_ensl.org.`date +%F`.sql mv 00_ensl.org.`date +%F`.sql db/initdb.d/00_ensl.org.`date +%F`.sql diff --git a/bin/script/entry.sh b/bin/script/entry.sh index 5ba01bc..6ea2280 100755 --- a/bin/script/entry.sh +++ b/bin/script/entry.sh @@ -23,6 +23,6 @@ if [ "$ASSETS_PRECOMPILE" -eq 1 ]; then chown -R web:web $APP_PATH fi -cd $APP_PATH +bundle exec rake db:migrate bundle exec puma -C config/puma.rb bash diff --git a/script/dump_db.sh b/script/dump_db.sh new file mode 100644 index 0000000..5935441 --- /dev/null +++ b/script/dump_db.sh @@ -0,0 +1,6 @@ +#!/bin/bash +# ENSL_DB_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' ensl_db) + +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" + +docker-compose exec db "mysqldump --opt -u $MYSQL_USER -p $MYSQL_PASSWORD $MYSQL_DATABASE" > $DIR/db/initdb.d/ensl.org.`date +%F`.sql \ No newline at end of file