diff --git a/scripts/setup/restore-backup b/scripts/setup/restore-backup index 8dce08b263..f6814677d4 100755 --- a/scripts/setup/restore-backup +++ b/scripts/setup/restore-backup @@ -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"),