# 如何将 Discourse 从一台服务器迁移到另一台服务器，使用相同的 DNS 名称

**URL:** <https://meta.discourse.org/t/how-to-migrate-discourse-from-one-server-to-another-with-the-same-dns-name/175572>\
**Category:** Self-hosting\
**Created:** [2021 年1 月 9 日 05:03 UTC](https://meta.discourse.org/t/how-to-migrate-discourse-from-one-server-to-another-with-the-same-dns-name/175572 "2021-01-09T05:03:08Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

作者： ![RBoy](https://avatars.discourse-cdn.com/v4/letter/r/2bfe46/32.png) [@RBoy](https://meta.discourse.org/u/RBoy)\
发布日期： [2021 年1 月 9 日 05:03 UTC](https://meta.discourse.org/t/how-to-migrate-discourse-from-one-server-to-another-with-the-same-dns-name/175572/1 "2021-01-09T05:03:08Z")

</div>

我正准备将 Discourse 从个人托管迁移到 Amazon LightSail 服务器。我已搜索过论坛，并阅读了所有关于迁移服务器和设置 Discourse 的帖子：

[Move your Discourse Instance to a Different Server](https://meta.discourse.org/t/move-your-discourse-instance-to-a-different-server/15721)  
[Restore a backup from the command line](https://meta.discourse.org/t/restore-a-backup-from-command-line/108034)  
[How To Install Discourse on Ubuntu 18.04 | DigitalOcean](https://www.digitalocean.com/community/tutorials/how-to-install-discourse-on-ubuntu-18-04)  
[discourse/docs/INSTALL-cloud.md at main · discourse/discourse · GitHub](https://github.com/discourse/discourse/blob/master/docs/INSTALL-cloud.md)

据我理解，流程如下：

1. 安装新的 Discourse 服务器
2. 从现有 Discourse 导出备份（目前备份配置为保存到 S3，但我理解这需要手动文件备份）
3. 将备份导入新 Discourse（由于无法从 S3 自动获取，需手动操作）

现在我在第 1 步卡住了，因为我有几个限制条件：我只有一个域名，希望新服务器使用相同的域名，并且不想有任何停机时间（我的目标是完成新服务器设置、恢复备份，最后更改 DNS 记录指向新服务器，从而避免停机，因为两台服务器将同时运行）。

据我理解，设置新 Discourse 服务器时，我可以从现有服务器复制 `app.yml` 到新服务器，然后运行 `discourse-setup`。但我看到的问题是：这样做会使用与现有服务器相同的 DNS 名称（这正是我想要的），但我预见到两个问题，正在试图解决：

1. Let’s Encrypt 无法为新服务器生成 SSL 证书，因为域名仍指向旧服务器。
2. 由于没有 SSL 证书（旧服务器配置设置为仅使用 SSL，这将随 `app.yml` 一起迁移），服务器将无法启动。
3. 我曾尝试通过 DNS 名称重定向连接到 Discourse 服务器，但如果输入的 URL 与 `app.yml` 配置不匹配，NGINX 或 Discourse 将无法工作，您在尝试连接时会在浏览器中收到错误。因此，没有 Web 界面，我无法启动恢复过程。

那么，我该如何使用现有服务器的 `app.yml` 完成新 Discourse 服务器的设置，然后恢复备份并进行 DNS 切换？或者是否有更简单的方法？

---

_[View the full topic](https://meta.discourse.org/t/how-to-migrate-discourse-from-one-server-to-another-with-the-same-dns-name/175572)._
