# 面向自托管用户的 PostgreSQL 18 更新

**URL:** <https://meta.discourse.org/t/postgresql-18-update-for-self-hosters/406194>\
**Category:** Announcements\
**Created:** [2026年八月3日 04:36 UTC](https://meta.discourse.org/t/postgresql-18-update-for-self-hosters/406194 "2026-08-03T04:36:42Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![chrisr](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/chrisr/32/246622_2.png) [@chrisr](https://meta.discourse.org/u/chrisr)\
**Post date:** [2026年八月3日 06:23 UTC](https://meta.discourse.org/t/postgresql-18-update-for-self-hosters/406194/6 "2026-08-03T06:23:52Z")

</div>

> [@Ed\_S](#):
>
> 如果磁盘空间不足，会发生什么样的“优雅”故障？肯定有人会遇到这种情况！

升级脚本会检查可用空间，仅在安全的情况下才会继续执行。

在升级过程中有两个步骤可能会面临磁盘空间不足的问题。如果您绕过可用空间检查，就可能会在此处遇到问题：

1. 运行 pg\_dump 从旧数据库提取数据时（此时需要 2 倍于数据库大小的存储空间）。
2. 运行 pg\_restore 将数据插入新数据库时（此时需要 3 倍于数据库大小的存储空间）。

要从此状态恢复，您需要删除 `/shared/postgres_dump` 和 `/shared/postgres_data_new`。

请注意，在升级结束时，我们会删除临时的 pg\_dump 文件，但会保留升级前的数据库数据于 `/shared/postgres_data_old` 中，以防万一。一旦您确认一切正常运行，您可能希望删除该目录以释放磁盘空间。

> [@Ed\_S](#):
>
> 对于磁盘空间不足的用户，先备份然后恢复到全新安装作为迁移方案，这样可行吗？

我测试了在 PG15 站点上创建 Discourse 备份，然后将其恢复到 PG18 站点上。这对我有效，但请注意，这不是官方支持的方法。请先在非生产环境中进行彻底测试，并确保您有回滚方案！

我建议您研究升级脚本使用的流程。如果您有特殊的存储需求，应该能够将其调整为适合您的需求。同样，请先进行测试：

> <https://github.com/discourse/discourse_docker/blob/09493049db7e4873f3dcff1356249ccf879ca6ec/templates/postgres.18.template.yml#L152-L161>

> [@Richie](#):
>
> 确认一下，这现在已经部署了吗？
> 
> 如果我稍后通过命令行更新，这一切都会自动执行吗？

是的，这已经 [集成到 discourse\_docker 中](https://github.com/discourse/discourse_docker/commit/09493049db7e4873f3dcff1356249ccf879ca6ec)。如果您拉取 `main` 分支或运行 `./launcher rebuild app`，您将获得此功能。

如果您想推迟升级，将 discourse\_docker 从 `main` 分支切换出去可以 [帮助防止意外升级](https://github.com/discourse/discourse_docker/blob/cac591067e2b94c796835df783b7ee30d5f9206b/launcher#L831)。

---

_[View the full topic](https://meta.discourse.org/t/postgresql-18-update-for-self-hosters/406194)._
