# 升级到最新版后，所有数据都丢失了

**URL:** <https://meta.discourse.org/t/i-upgraded-to-latest-and-lost-everything/409647>\
**Category:** Self-hosting\
**Tags:** multisite\
**Created:** [2026年八月9日 22:37 UTC](https://meta.discourse.org/t/i-upgraded-to-latest-and-lost-everything/409647 "2026-08-09T22:37:23Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![kcahtoor](https://avatars.discourse-cdn.com/v4/letter/k/9de0a6/32.png) [@kcahtoor](https://meta.discourse.org/u/kcahtoor)\
**Post date:** [2026年八月10日 03:15 UTC](https://meta.discourse.org/t/i-upgraded-to-latest-and-lost-everything/409647/5 "2026-08-10T03:15:20Z")

</div>

所以我检查了 PostgreSQL 模板文件。它只针对一个数据库。这太荒谬了。它本应该遍历现有的数据库并对其进行更改。我把这个留在这里，供任何在此场景下寻找解决方案的人参考

```bash
DB_LIST=$(su postgres -c "/usr/lib/postgresql/${PG_MAJOR_OLD}/bin/psql -p 5432 -tAc \"select datname from pg_database where not datistemplate and datname != 'postgres'\"")

for DB in $DB_LIST; do
  su postgres -c "/usr/lib/postgresql/${PG_MAJOR_OLD}/bin/pg_dump -Fd -j$(nproc --ignore=1) \"$DB\" -f /shared/postgres_dump/\"$DB\""
done

```

---

_[View the full topic](https://meta.discourse.org/t/i-upgraded-to-latest-and-lost-everything/409647)._
