# PostgreSQL 18 update for self-hosters

**URL:** https://meta.discourse.org/t/postgresql-18-update-for-self-hosters/406194
**Category:** Announcements
**Created:** [August 3, 2026, 4:36am 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:** 43

<div class="post-metadata">

### Author: ![Lilly](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/lilly/32/575047_2.png) [@Lilly](https://meta.discourse.org/u/Lilly)
#### Post date: [August 6, 2026, 1:14am UTC](https://meta.discourse.org/t/postgresql-18-update-for-self-hosters/406194/43 "2026-08-06T01:14:56Z")

</div>

i just did the PostgreSQL 18 for a [standard install](https://meta.discourse.org/t/142537?silent=true) and a [dual container](https://meta.discourse.org/t/move-from-standalone-container-to-separate-web-and-data-containers/29413) without any issues at all. thanks again @chrisr and team for the easy instructions.

for a dual container configuration behind Cloudflare CDN with R2 uploads/backup buckets, the steps i used were as follows:

### Step 1: disk cleanup

```bash
# nuke all unused docker data
docker system prune -a -f

```

```bash
# clear old logs and apt cache
journalctl --vacuum-time=2d
apt-get clean
apt-get autoremove -y

```

```bash
# check database size
du -sh /var/discourse/shared/data/postgres_data*

```

```bash
# check new available free space
df -h -x tmpfs -x devtmpfs

```

### Step 2: maintenance & backup

1. edit a Cloudflare maintenance page to say 15-20 minutes system maintenance update (may not take this long, but good to be safe!) and set a reload timer of 30 seconds or so. turn on a Cloudflare worker route to show the maintenance page.

 ![image](https://global.discourse-cdn.com/meta/original/4X/8/e/8/8e8c850527c5101620a937a9e5f13411073dbc02.png)

1. trigger a backup via command line:

```bash
cd /var/discourse
./launcher enter web_only
discourse backup
exit

```

1. log into Cloudflare R2 dashboard and check the backup folder to confirm the backup file was successfully uploaded

### Step 3: safe shutdown

1. stop the web container first to kill any active connections, then stop the database container:

```bash
cd /var/discourse
./launcher stop web_only
./launcher stop data

```

1. verify that PostgreSQL shut down properly:

```bash
tail -n 20 shared/data/log/var-log/postgres/current

```

### Step 4: upgrade rebuilds

run the following commands in this order:

```bash
./launcher rebuild data # dumps, migrate and restore postgresql 18
./launcher rebuild data # rebuilds database container
./launcher rebuild web_only # rebuilds web app

```

### Step 5: optimization & cleanup

1. generate the missing pg18 table stats, otherwise the forum will be slower than normal:

```bash
docker exec -u postgres data /usr/lib/postgresql/18/bin/vacuumdb -d discourse --analyze-in-stages

```

1. test the forum to ensure everything is working - maintenance page should not be loading now if you have a reload timer set on it.
2. remove the Cloudflare worker route to the maintenance page (we don’t want to hit the 100,000 daily limit!)
3. delete the old pg18 data to reclaim that disk space:

```bash
rm -fr /var/discourse/shared/data/postgres_data_old/

```

**done!** 🥳 🍻

---

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