Merge "Fix mysql migration script to handle errors."
This commit is contained in:
commit
c75d89128b
@ -16,6 +16,7 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
set -eux
|
set -eux
|
||||||
|
set -o pipefail
|
||||||
|
|
||||||
# Quietly go away unless a migration has been asked for
|
# Quietly go away unless a migration has been asked for
|
||||||
DEFAULTS=/etc/mysql/migration_default
|
DEFAULTS=/etc/mysql/migration_default
|
||||||
@ -52,15 +53,16 @@ local_mysql -e 'SHOW GRANTS'
|
|||||||
if [ -n "$MIGRATION_HOST" ] ; then
|
if [ -n "$MIGRATION_HOST" ] ; then
|
||||||
local_mysql -e 'STOP SLAVE' || :
|
local_mysql -e 'STOP SLAVE' || :
|
||||||
# If we are planning on setting up a full slave
|
# If we are planning on setting up a full slave
|
||||||
|
SLAVE_OPTS=""
|
||||||
if [ -n "$MIGRATION_USER" ] && [ -n "$MIGRATION_PASSWORD" ] ; then
|
if [ -n "$MIGRATION_USER" ] && [ -n "$MIGRATION_PASSWORD" ] ; then
|
||||||
local_mysql -e "CHANGE MASTER TO master_host='${MIGRATION_HOST}', master_user='${MIGRATION_USER}', master_password='${MIGRATION_PASSWORD}'"
|
local_mysql -e "CHANGE MASTER TO master_host='${MIGRATION_HOST}', master_user='${MIGRATION_USER}', master_password='${MIGRATION_PASSWORD}'"
|
||||||
|
SLAVE_OPTS="--master-data"
|
||||||
fi
|
fi
|
||||||
mysqldump --defaults-extra-file=/root/metadata.my.cnf \
|
mysqldump --defaults-extra-file=/root/metadata.my.cnf \
|
||||||
-u $MIGRATION_DUMP_USER
|
-u $MIGRATION_DUMP_USER \
|
||||||
--single-transaction \
|
--single-transaction \
|
||||||
--all-databases \
|
--all-databases \
|
||||||
--master-data \
|
$SLAVE_OPTS -h $MIGRATION_HOST | local_mysql
|
||||||
-h $MIGRATION_HOST | local_mysql
|
|
||||||
|
|
||||||
# After this following command, our ~/.my.cnf may stop working as its
|
# After this following command, our ~/.my.cnf may stop working as its
|
||||||
# password may change due to the dump loaded above.
|
# password may change due to the dump loaded above.
|
||||||
|
Loading…
Reference in New Issue
Block a user