Here is a full summary of the solution that worked for me:
1. Make sure Immich is running on Postgres 15
If you already switched to PG18 and it’s failing, edit the app and set the Postgres Image dropdown back to Postgres 15. Save and redeploy. Confirm Immich is running.
2. Dump the database
Open the TrueNAS Shell and run:
sudo docker exec ix-immich-pgvecto-1 pg_dumpall -U immich > /mnt/<your-path>/immich_db_backup.sql
Replace /mnt/<your-path>/ with a location on your pool (e.g. alongside your Immich data). The username (immich) may differ on your setup. You can check with:
sudo docker exec ix-immich-pgvecto-1 env | grep POSTGRES_USER
Verify the dump file is a reasonable size (likely hundreds of MB if you have a lot of photos):
ls -lh /mnt/<your-path>/immich_db_backup.sql
3. Stop Immich
Stop the app from the TrueNAS UI.
4. Clear the PG15 database directory
sudo rm -rf /mnt/<your-postgres-data-path>/db/*
This is wherever you configured “Postgres Data Storage” in the Immich app settings. Do NOT delete the db folder itself if it’s a ZFS dataset, just its contents.
5. Switch to Postgres 18
Edit the Immich app, change the Postgres Image dropdown to Postgres 18, save and start. PG18 will initialize a fresh empty database. Immich will show the first-time setup screen. That’s expected.
6. Stop the Immich server (keep Postgres running)
sudo docker stop ix-immich-server-1
sudo docker stop ix-immich-machine-learning-1
7. Drop the empty database and restore
sudo docker exec ix-immich-pgvecto-1 dropdb -U immich immich
sudo docker exec ix-immich-pgvecto-1 createdb -U immich immich
sudo docker exec -i ix-immich-pgvecto-1 psql -U immich immich < /mnt/<your-path>/immich_db_backup.sql
This will take a while depending on database size. Let it run until you get your prompt back. You should see clean output (CREATE TABLE, COPY, CREATE INDEX, etc.) with no errors.
Important: Make sure the Immich server and machine-learning containers are stopped before running the restore. If other sessions are connected to the database, the dropdb command will fail.
8. Restart Immich
Stop and Start the app from the TrueNAS UI. Open Immich in your browser. All your photos, albums, users, and face recognition data should be back.
9. Clean up
Once everything is confirmed working, you can delete the old backup:
sudo rm /mnt/<your-path>/immich_db_backup.sql