Restoring 1.119.1 DB to 1.131.2 fails on Smart Search data

I'm trying to update my TrueNAS server from 24.04 to 24.10 and Immich along with it. My Immich db is not being migrated automatically by TrueNAS for some reason; Immich starts as if it's a brand new server. All of my images and users are gone on 24.10 with 1.131.2. So I took a postgres backup from the working kubernetes and am trying to restore it to the new docker container. I'm following the steps outlined here, just with a few modifications on the restore process: https://github.com/immich-app/immich/discussions/10906 My restore begins working but fails trying to copy Smart Search data
COPY 0
ERROR: pgvecto.rs: Bad literal.
INFORMATION: hint = Bad sequence.
CONTEXT: COPY smart_search, line 25928, column embedding: "[-0.012000048, -0.026440227, -0.020461267, -0.012008893, 0.0068139997, 0.002615924, 0.017675625, 0.0..."
COPY 0
ERROR: pgvecto.rs: Bad literal.
INFORMATION: hint = Bad sequence.
CONTEXT: COPY smart_search, line 25928, column embedding: "[-0.012000048, -0.026440227, -0.020461267, -0.012008893, 0.0068139997, 0.002615924, 0.017675625, 0.0..."
My postgres database location in the TrueNAS Immich App config is the default ixVolumes. I stopped the immich containers other than pgvecto during restore and dropped and recreated the immich db so it's fresh. Looking for any help on how I can fix the DB on 1.119.1 to get a working dump, or get TrueNAS to migrate immich correctly. I tried rerunning Smart Search job on 1.119.1 for All in the Immich Admin but this did not fix the issue after doing another dump. Thanks for any assistance!
19 Replies
Immich
Immich4w ago
:wave: Hey @candyman, Thanks for reaching out to us. Please carefully read this message and follow the recommended actions. This will help us be more effective in our support effort and leave more time for building Immich :immich:. References - Container Logs: docker compose logs docs - Container Status: docker ps -a docs - Reverse Proxy: https://immich.app/docs/administration/reverse-proxy - Code Formatting https://support.discord.com/hc/en-us/articles/210298617-Markdown-Text-101-Chat-Formatting-Bold-Italic-Underline#h_01GY0DAKGXDEHE263BCAYEGFJA Checklist I have... 1. :blue_square: verified I'm on the latest release(note that mobile app releases may take some time). 2. :blue_square: read applicable release notes. 3. :blue_square: reviewed the FAQs for known issues. 4. :blue_square: reviewed Github for known issues. 5. :blue_square: tried accessing Immich via local ip (without a custom reverse proxy). 6. :blue_square: uploaded the relevant information (see below). 7. :blue_square: tried an incognito window, disabled extensions, cleared mobile app cache, logged out and back in, different browsers, etc. as applicable (an item can be marked as "complete" by reacting with the appropriate number) Information In order to be able to effectively help you, we need you to provide clear information to show what the problem is. The exact details needed vary per case, but here is a list of things to consider: - Your docker-compose.yml and .env files. - Logs from all the containers and their status (see above). - All the troubleshooting steps you've tried so far. - Any recent changes you've made to Immich or your system. - Details about your system (both software/OS and hardware). - Details about your storage (filesystems, type of disks, output of commands like fdisk -l and df -h). - The version of the Immich server, mobile app, and other relevant pieces. - Any other information that you think might be relevant. Please paste files and logs with proper code formatting, and especially avoid blurry screenshots. Without the right information we can't work out what the problem is. Help us help you ;) If this ticket can be closed you can use the /close command, and re-open it later if needed.
Zeus
Zeus4w ago
You should restore to 1.119 first of all
candyman
candymanOP4w ago
The restore should work regardless of which immich version I'm restoring for though, right? The pgvecto container on TrueNAS 24.04 and 24.10 are running PostgreSQL 15.12 so the dump should be compatible. I'm following essentially this process recommended by Immich https://immich.app/docs/administration/backup-and-restore/#manual-backup-and-restore
Zeus
Zeus4w ago
Are you sure it’s the identical version of vectors as well as pg 15.2 on both servers?
candyman
candymanOP4w ago
Yep, checked the image and ran SELECT version(); on both containers. I'm stumped
Zeus
Zeus4w ago
How did you check or confirm the vectors version
candyman
candymanOP4w ago
I checked the images used in kubernetes and docker - they're both using pgvecto-rs:pg15-v0.2.0 so pgvector 0.2.0 it seems
Zeus
Zeus4w ago
Can you show the full command output of how you made the backup, any output, and the restore and full output
Zeus
Zeus4w ago
Theres tons of errors in there You are not restoring into a fresh DB. As the logs say its critical that immich has not atarted up yet you're also not following our docs, specifically --dbname is missing
candyman
candymanOP4w ago
Those are skippable errors though I believe, I just didn't clear the db out from my last restore attempt there. The COPY error is the real issue here. It fails at the same point when I drop and recrate the immich db and there aren't a ton of errors, see the attached output which is a fresh immich db. The immich server container is stopped while I'm working on the db container. Sorry, I think I messed up that output; let me correct it
Zeus
Zeus4w ago
can you please share line 25928 with context from the dump.sql.gz
candyman
candymanOP4w ago
Here's lines 25927 through 25929 - nothing weird jumping out to me 🤔
$ cat -n dump_clean.sql | awk '$1>=25927 && $1<=25929'
25927 42f4134d-46e2-4682-bc59-ededda66b9f2 \N 1600 1200 519 349 580 425 f6c654c8-453d-4a42-945b-b75e58d4b3bc machine-learning
25928 42f4134d-46e2-4682-bc59-ededda66b9f2 \N 1600 1200 1228 316 1299 401 3a6b1623-4303-4f6b-a8c4-c5fac8c55750 machine-learning
25929 42f4134d-46e2-4682-bc59-ededda66b9f2 \N 1600 1200 1373 417 1468 532 92d9c8f1-f16d-496c-b57e-b49bc5778f74 machine-learning
$ cat -n dump_clean.sql | awk '$1>=25927 && $1<=25929'
25927 42f4134d-46e2-4682-bc59-ededda66b9f2 \N 1600 1200 519 349 580 425 f6c654c8-453d-4a42-945b-b75e58d4b3bc machine-learning
25928 42f4134d-46e2-4682-bc59-ededda66b9f2 \N 1600 1200 1228 316 1299 401 3a6b1623-4303-4f6b-a8c4-c5fac8c55750 machine-learning
25929 42f4134d-46e2-4682-bc59-ededda66b9f2 \N 1600 1200 1373 417 1468 532 92d9c8f1-f16d-496c-b57e-b49bc5778f74 machine-learning
Zeus
Zeus4w ago
@sogan Any thoughts? can you post the output of the following from both old and new PG
select version();
SELECT * FROM pg_extension;
select version();
SELECT * FROM pg_extension;
can you also post the postgres logs?
sogan
sogan4w ago
The string representation for the data should be the same for any pgvecto.rs version so I kinda doubt it’s the issue. Are these backups generated by immich or by truenas? They used to do their own automatic db backups before any immich upgrade If it was generated by truenas, then it could maybe be that the backup is done in a different way, like a different string encoding or something
candyman
candymanOP4w ago
sudo k3s kubectl exec -it immich-postgres-6559858866-fd8b4 -n ix-immich -- sh -c "pg_dumpall --clean --if-exists --username=immich" | gzip > /home/admin/dump_clean.sql.gz
sudo k3s kubectl exec -it immich-postgres-6559858866-fd8b4 -n ix-immich -- sh -c "pg_dumpall --clean --if-exists --username=immich" | gzip > /home/admin/dump_clean.sql.gz
I generated the backup from the TrueNAS shell (zsh I think?) using pg_dumpall over the kubectl exec shell. Tried with BASH just now, same result. TrueNAS did leave backups in pgBackup (I think they're generated every time the App is updated) - image attached. The latest was quite old though so I thought I would generate a new one as recommended in the docs and by other people.
No description
candyman
candymanOP4w ago
@Zeus
No description
candyman
candymanOP3w ago
SOLVED: I was able to manually fix my database and migrate to Immich 1.131.3 on TrueNAS 24.10. Details here: https://forums.truenas.com/t/immich-app-postgres-database-does-not-migrate-from-24-04-to-24-10/38207/2?u=candyman
TrueNAS Community Forums
Immich App postgres Database does not migrate from 24.04 to 24.10
RESOLUTION I was finally able to fix this issue with a lot of trial and error. I manually migrated my immich database to Immich 1.131.3 on 24.10. Currently rebuilding smart search data and hoping everything works; it looks good so far! If anyone runs into this in the future as more people upgrade, good luck! I still have no idea why TrueNAS wa...

Did you find this page helpful?