Easiest way to restore immich
From reddit, copy pasted
Hello, I tried to migrate to the new storage system in my TrueNAS scale, and it went horribly. My dataset info is irretrievably corrupted.
I want to make a fresh installation of Immich. What do you think is the best way to proceed? Delete everything except the library and reinstall?
What is the best way to keep the library and the dataset in different pools? Before I could specify a different path, but now everything is under data.
@Xiticks
63 Replies
:wave: Hey @tdp,
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.You could, but we need to check if the originals are in upload or library
Why do you say it's irretrievably corrupted ?
You touched the "originals" datasets or did rsync commands?
Both, I think all datasets are somewhat ok, but the video (encoded-video), which is 100% lost
if this is a roadblock we have our answer
well
that's one that isn't important
so you're fine 😄
They can be regenerated
Can you show me your current dataset structure?
And if already created one for the "new" install, show it also
created new, resynched what I had.
Library folder is empty, it's on another disk (mechanical) and I would like to keep it there tbh)

config is

Ok, so your "library" is an external library in Immich, correct ?
sorru my sentence wasn't clear
In the previous configuration, every dataset had its own path, so I am unsure what defines an external library. It was mounted on another disk. now everything is supposed to be under data. This is somewhat against my typical TrueNAS practices (large data on the main tank on HDD with conservative raid setting, app configurations and databases on the app tank on SSD wiht less safe raid settings). I neither want the database on the hdd nor the photos on the ssd (also because the ssd is not large enough)
oh yeah so this is "current"
it wasn't like that before
Before it was the old config, I could try it, the dataset """should"""" be still there
No but so library was map to library in the old config, it what I meant
(sorry I'm also troubleshooting another issue)
Yes, I never touched the library in this failed migration
In principle I can delete the database, create a new profile from scratch and mass dump the library again.
Yeah, but no real need
so what does Immich throws when you start it?
As errors? I mean
with the config I showed you... nothing. Greets me as a new user, prompts me to create an admin profile and then it bare and empty
no photo, no data, no nothing
following some stupid advices from ai I also tried to mount the library in /usr/src/app/upload/
this breaks everything, and immich is not able to run as it cannot read data/encoded-video/.immich
yeah this has been changed
but we will go back to the beginning
Where is/was stored your previous postgresData ?
Exactly in the folder I mount now
I did create a new folder, copied everything (copy-paste via SMB...), then rsynched back again to the original one (since I realized what I was doing was stupid and not necessary)
And in backups, do you have stuff?
YEs, same story, created folder, copy pasted by hand and then rsynched back
yeah, but you have "zip" fiiles in it right?

Yeah, so that is good
Brb in 5 min
But we will restore your Immich without issues
Can you access your Truenas through ssh tho?
Would be better
It's in the local network, so I have access to the root shell from the GUI
Yeah, that also works (ssh is just to avoid being disconnected)
With TrueNAS shell, can you cd into your pgData ?
And do ll there
Stop the Immich app first
done
Can you share the output of the
ll
command inside the shell?well yeah, makes sense as you set a new user
can you do
rm -r *
while still in pgDatadone
OK
Can you tell me on which Immich version you were on if you remember?
before the migration failed
and also, did you try to migrate on the 28th or 29th ?
29th, on 28th I was in the old config
I do not remember the versioning, I keep my app updated, but i have a vague memory that immich did not update itself for the deprecated storage
Yeah ok, so you were probably on more than 1.132
Can you edit your Immich app now?
There you can add an additional env variable
there is a button for it
Click on add. The variable is and value should be
doen
done*
now, you also edit you mount path for the library
set it to /data/library
then you click on "update"
Don't start the app yet
you mean here
?

You said that encoded-video was corrupted, right?
Yes
mount or host to /data/library
?
the mount path inside Immich is /data/internal_Immich_folder
so mount
more than corrupted, empty
Host, well you keep the info where your library is
Oh well, that is fine then 😄
Done (like this)

I lost some snapshot idk how
and deleted the dataset out of stress
Well that's ok, you'll make Immich regenerate them
So now, you can start Immich
(It won't work yet, don't worry)
it's looping deploying and running
Normal
It's in a state where the databse isn't initialised
You have to execute this in the shell
replacing
path/to/backup.gz
with the path of the latest backup there
full path I meant
so smth like /mnt/apps-pool/Apps/immich/backups/immich...20250928...
I won't type the whole backup name, you can copy it from your terminal or smb share
If you need more help/details/want me to doublecheck your command, you can askI tried
gunzip --stdout "/mnt/apps-pool/Apps/immich/backups/immich-db-backup-20250928T020000-v1.142.1-pg15.14.sql.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
but got a permission denied, about to try with sudooh mb
always forget that
sudo su
first
(to "login" as root)
then run the commanddone
I suppose it output lines in the terminal?
yes went full matrix
If so, edit the immich app again, and remove the env variable
done
Restart Immich app
And in theory, it should work
Well we will double check that
it's still looping deploying and runing :/
data/encoded-video is empty (no .immich)
Oh yeah
so cd into it from shell
(into encoded-video)
and do
what the heck
well ok after 20 edits, here is the correct command
Then you might need to restart Immich again
And if it throws another error, we continue from there
wowo seems to work
Can you try to download one or multiple images/video (random time point)
Click on them then upper right corner 3dots button, then download
(just to verify that Immich read your library
from your HDD
If that works
go in there
https://my.immich.app/admin/jobs-status
And run the "Generate Thumbnails" and "Transcode videos" jobs on "all"
yes aI can download
i cannot understand what to do in the link
enter your immich link or IP (if you don't have a domain for your Immich)
This way it redirects you on the right page on your instance (that's an official Immich thing)
i sent the job
1) Do I need to do something on my android immich app
2) can i delete che old config datasets?
1) No (well update it if it's not up to date)
2) Yes you can, but ensure that you delete the old one and not the newly created ones (or a combination of both :D)
Otherwise it would be even harder to recover
It seems that the android app wants to re-upload everything

Enable the backup, then it will hash all photos, and it should only upload the ones that aren't backed up yet
Without enabling backup, it did not hash anything yet, so it can't compare with what the server already has
:peepoAwesome: