restore-backup: Run configure-rabbitmq to update RABBITMQ_PASSWORD.

Previously, if you restored onto a different production system from
the one where you took the backup, backup restoration would fail
because the generated rabbitmq passwords for the two systems would be
different, and we didn't update the restored system to use the
password from the original system.

Fixes #12114.
This commit is contained in:
Tim Abbott 2019-06-06 16:35:52 -07:00
parent 3c4030a421
commit 5748bae71d
1 changed files with 18 additions and 3 deletions

View File

@ -99,10 +99,25 @@ def restore_backup(tarball_file):
run(as_postgres + ["dropdb", "--if-exists", "--", db_name])
run(as_postgres + ["createdb", "-O", "zulip", "-T", "template0", "--", db_name])
# In production, we also need to do a `zulip-puppet-apply` in
# order to adjust any configuration from /etc/zulip/zulip.conf
# to this system.
if settings.PRODUCTION:
# If there is a local rabbitmq, we need to reconfigure it
# to ensure the rabbitmq password matches the value in the
# restored zulip-secrets.conf. We need to be careful to
# only do this if rabbitmq is configured to run locally on
# the system.
rabbitmq_host = subprocess.check_output(
[os.path.join(settings.DEPLOY_ROOT,
"scripts", "get-django-setting"),
"RABBITMQ_HOST"]).strip().decode("utf-8")
if rabbitmq_host in ["127.0.0.1", "::1", "localhost", "localhost6"]:
run([os.path.join(settings.DEPLOY_ROOT,
"scripts", "setup", "configure-rabbitmq")])
# In production, we also need to do a `zulip-puppet-apply`
# in order to apply any configuration from
# /etc/zulip/zulip.conf to this system, since it was
# originally installed without the restored copy of that
# file.
run(
[
os.path.join(settings.DEPLOY_ROOT, "scripts", "zulip-puppet-apply"),