Database Restoration on TrueNAS

I tried to migrate my existing setup from an HDD to an SSD and everything is verbatim the same. Unfortunately on Immich you need to also do a manual restoration of the database as I can't really see any users while still having all of the data on the datasets. I did read the restoration guide on the website but I don't think it's possible for me to implement this on TrueNAS apps.
61 Replies
Immich
Immich7d ago
:wave: Hey @AZA?ZAA?zur, 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. :ballot_box_with_check: verified I'm on the latest release(note that mobile app releases may take some time). 2. :ballot_box_with_check: read applicable release notes. 3. :ballot_box_with_check: reviewed the FAQs for known issues. 4. :ballot_box_with_check: reviewed Github for known issues. 5. :ballot_box_with_check: tried accessing Immich via local ip (without a custom reverse proxy). 6. :ballot_box_with_check: uploaded the relevant information (see below). 7. :ballot_box_with_check: 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.
AZA?ZAA?zur
AZA?ZAA?zurOP7d ago
I don't think most of the information wanted on this checklist matters as I use TrueNAS apps for downloading and using Immich. If it helps I applied the exact same settings as my previous HDD setup. I'm pretty sure the issue is with the database restoration (which i can not do (at least i think so))
Immich
Immich7d ago
Successfully submitted, a tag has been added to inform contributors. :white_check_mark:
AZA?ZAA?zur
AZA?ZAA?zurOP7d ago
I am talking about this bit here: https://docs.immich.app/administration/backup-and-restore#manual-backup-and-restore I do have the automatic database backup available but I can't seem to restore it without using docker-compose, am I correct in my thinking?
Xiticks
Xiticks7d ago
So you created both datasets on the SSD and copied everything over? Or you did it using zfs replication? Can you show the old and new datasets as well as the immich config It is possible to restore with the backup (tip section) but I don't think that would be that necessary. It would be the safest to do, but I just need/want to undersdand your setup first. Also why did you move everything to an SSD? It's not required to move everything to there to have Immich perfom "good"
AZA?ZAA?zur
AZA?ZAA?zurOP7d ago
Unfortunately because of my setup I couldn't do a zfs replication. I just used an SFTP connection to download everything to my actual computer and when I installed the SSD resent everything. I checked the data integrity so I am 99% sure that's not the case. The reason why I moved everything to an SSD is because one of my HDD's failed so I took this as an opportunity to move mission critical data to a MIRRORed SSD setup so that my remaining single HDD could be used for Jellyfin/media storage (which is not mission critical data) sending over the datasets, one second
AZA?ZAA?zur
AZA?ZAA?zurOP7d ago
inside data obviously there are the required files needed for immich to function as stated on the guide. this was exactly the same before
No description
AZA?ZAA?zur
AZA?ZAA?zurOP7d ago
I deleted the pgdata contents because the app would refuse to start unless it created its own i still have a backup of them on my computer of course
AZA?ZAA?zur
AZA?ZAA?zurOP7d ago
here is my immich configuration on truenas apps (if that can be of any help)
No description
No description
Xiticks
Xiticks7d ago
Yes, I’ll have a look at it in 5 minutes
AZA?ZAA?zur
AZA?ZAA?zurOP7d ago
thank you very much 🙏 im in no rush
Xiticks
Xiticks7d ago
Why do you have Immich user and group set to 0 (which is root)
AZA?ZAA?zur
AZA?ZAA?zurOP7d ago
I honestly have no idea, I just replicated the previous settings which was 0 instead of 568 previously it worked fine
Xiticks
Xiticks7d ago
Oh make sense, well it's just a bit more secure to not run apps as root (from what I've read) so if you want this can also be changed to be 568, which is the uuid of the "apps" user and group TrueNAS uses in the data dataset, do you have a "backup" folder?
AZA?ZAA?zur
AZA?ZAA?zurOP7d ago
yes, there is a backups folder let me send the entire structure
AZA?ZAA?zur
AZA?ZAA?zurOP7d ago
No description
AZA?ZAA?zur
AZA?ZAA?zurOP7d ago
Oh alright, I'll keep that in mind! But I don't think this will fix my situation (?) i'll try it anyway
Xiticks
Xiticks7d ago
No, well we can do both at the same time can you show the content of it?
AZA?ZAA?zur
AZA?ZAA?zurOP7d ago
No description
Xiticks
Xiticks7d ago
Ok nice, so there is a backup from yesterday that can be restored
AZA?ZAA?zur
AZA?ZAA?zurOP7d ago
yeah that's what i noticed, but couldn't restore it using the guide because it requires docker compose (i think)
Xiticks
Xiticks7d ago
It doesn't necesseraly, there is a another way explained in the tip section of the backup and restore, so: 1) Stop the Immich app 2) remove the content inside the pgData dataset 3) Edit the Immich app and add an environment variable Name is: DB_SKIP_MIGRATIONS Value is: true
No description
Xiticks
Xiticks7d ago
Then you save the config (click on update) and start Immich
AZA?ZAA?zur
AZA?ZAA?zurOP7d ago
hmmmm, i can't seem to even install immich as an app if the pgdata is filled with the old folders. can i just install it with this environmental variable without the pgdata data?
Xiticks
Xiticks7d ago
Does it throws an error?
AZA?ZAA?zur
AZA?ZAA?zurOP7d ago
yes. it throws an error if i try to install it with the old pgdata folders i can only start it with a fresh pgdata dataset which it fills by itself
Xiticks
Xiticks7d ago
Is this pgData empty now? If so point immich to it with the added variable this will avoid any migration/setup so Immich won't fill it up (it is somehat similar as only starting the database in the compsoe method)
AZA?ZAA?zur
AZA?ZAA?zurOP7d ago
okay yeah started it with the enviroment variable while pointing it to an empty pgdata dataset and it seems that it DID fill the dataset
Xiticks
Xiticks7d ago
Yeah maybe initial stuff We'll see with the "restore" command if that works If not it means that something was done incorrectly
AZA?ZAA?zur
AZA?ZAA?zurOP7d ago
immich is running right now but giving out errors which i am assuming is because of a lack of postgresql db
Xiticks
Xiticks7d ago
So now, in TrueNAS shell do (and modify FULL_NAME_OF_LATEST_BACKUP_GZ with the name of the latest backup in the backups folder):
sudo su
sudo su
then
gunzip --stdout "/mnt/DataStore/apps/immich/data/backups/FULL_NAME_OF_LATEST_BACKUP_GZ" | sed "s/SELECT pg_catalog.set_config('search_path', '', false);/SELECT pg_catalog.set_config('search_path', 'public, pg_catalog', true);/g" | docker exec -i ix-immich-pgvecto-1 psql --dbname=postgres --username=immich
gunzip --stdout "/mnt/DataStore/apps/immich/data/backups/FULL_NAME_OF_LATEST_BACKUP_GZ" | sed "s/SELECT pg_catalog.set_config('search_path', '', false);/SELECT pg_catalog.set_config('search_path', 'public, pg_catalog', true);/g" | docker exec -i ix-immich-pgvecto-1 psql --dbname=postgres --username=immich
AZA?ZAA?zur
AZA?ZAA?zurOP7d ago
i did try this before but forgot to change the name to ix-immich-pgvecto-1 let me try!
Xiticks
Xiticks7d ago
yeah, with trueNAS it's a bit different And without the variable it wouldn't have worked anyway as Immich would have started
AZA?ZAA?zur
AZA?ZAA?zurOP7d ago
i actually did try it with the variable! i just thought it didnt work because it did fill it with folders
AZA?ZAA?zur
AZA?ZAA?zurOP7d ago
i think that worked?
No description
Xiticks
Xiticks7d ago
Yep Now, you can edit immich again, and remove the variable then update/save (and it should restart the app) otherwise restart it
AZA?ZAA?zur
AZA?ZAA?zurOP7d ago
yeah tell me about it, it gives me a headache every single time i try to use cli for docker
Xiticks
Xiticks7d ago
Well if you need the docker container names you can just list them
AZA?ZAA?zur
AZA?ZAA?zurOP7d ago
yeah i can see them on portainer as well (you can also guess the names as theyre predictable) but theyre such a pain in the ass to type
AZA?ZAA?zur
AZA?ZAA?zurOP7d ago
hmmm the server container gives out this error and restarts itself, which i am assuming is a permissions issue
No description
Xiticks
Xiticks7d ago
How often do you need to use that though? I rarely use the cli on my TrueNAS setup Btw Does immich work now?
AZA?ZAA?zur
AZA?ZAA?zurOP7d ago
eh not that frequently but its still a pain in the ass when i need to use it
Xiticks
Xiticks7d ago
Either be perms, or it's possible that hidden files weren't moved Can you show the permissions on the "data" dataset?
AZA?ZAA?zur
AZA?ZAA?zurOP7d ago
ooooh yeah that could also be the case let me check
Xiticks
Xiticks7d ago
I can give you the "default" apps ACL so you could switch immich from 0 0 to 568 568
AZA?ZAA?zur
AZA?ZAA?zurOP7d ago
okay turns out the automatic permission didn't work and it was stuck on root trying it with 568 as we speak
Xiticks
Xiticks7d ago
No Automatic permissions in only on the pgData dataset
Xiticks
Xiticks7d ago
No description
Xiticks
Xiticks7d ago
On the data, you could set this as an acl
AZA?ZAA?zur
AZA?ZAA?zurOP7d ago
man that worked! i can access immich now!!!!!
Xiticks
Xiticks7d ago
this way apps and root will have access (root is for "you") while the "apps" is for Immich
AZA?ZAA?zur
AZA?ZAA?zurOP7d ago
thank god thank you so much 🙏 can i be of assistance in any way to this community to repay (dont really have much code knowledge though, just experience with trial and error 😄 )
Xiticks
Xiticks7d ago
No problem! Well you can always try to help other, report bug/issues (on GitHub) If you think about any feature that could make Immich (in your opinion), and that no one already talked about here: https://github.com/immich-app/immich/discussions you can suggest an idea (or upvote tohers)
AZA?ZAA?zur
AZA?ZAA?zurOP7d ago
well yeah actually the location feature doesn't seem to work quite right. it always names the district that is the most proximal to the actual district the photo was taken (so if a photo was taken in district a and district a is close to district b immich will say that that picture was taken in district b no matter what. let me see if anyone else has had this issue maybe its a regional thing but this always seems to be the case no matter where i am
Xiticks
Xiticks7d ago
It's already been reported well "reported" it's an expected behaviour the way Immich manages location
AZA?ZAA?zur
AZA?ZAA?zurOP7d ago
hmmm interesting
Xiticks
Xiticks7d ago
reverse geocoding*
AZA?ZAA?zur
AZA?ZAA?zurOP7d ago
well ill think of something else then! again, thank you so much for your help 🙏
Xiticks
Xiticks7d ago
https://discord.com/channels/979116623879368755/1430467960644046938 If you want to read another small thread about it No proble! you can /close the ticket
AZA?ZAA?zur
AZA?ZAA?zurOP7d ago
alright!
Immich
Immich7d ago
This thread has been closed. To re-open, use the button below.

Did you find this page helpful?