I
Immich•4d ago
tdp

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
Immich
Immich•4d ago
: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.
Xiticks
Xiticks•4d ago
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?
tdp
tdpOP•4d ago
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
Xiticks
Xiticks•4d ago
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
tdp
tdpOP•4d ago
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)
No description
tdp
tdpOP•4d ago
config is
No description
Xiticks
Xiticks•4d ago
Ok, so your "library" is an external library in Immich, correct ? sorru my sentence wasn't clear
tdp
tdpOP•4d ago
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)
Xiticks
Xiticks•4d ago
oh yeah so this is "current" it wasn't like that before
tdp
tdpOP•4d ago
Before it was the old config, I could try it, the dataset """should"""" be still there
Xiticks
Xiticks•4d ago
No but so library was map to library in the old config, it what I meant (sorry I'm also troubleshooting another issue)
tdp
tdpOP•4d ago
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.
Xiticks
Xiticks•4d ago
Yeah, but no real need so what does Immich throws when you start it? As errors? I mean
tdp
tdpOP•4d ago
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
Xiticks
Xiticks•4d ago
yeah this has been changed but we will go back to the beginning Where is/was stored your previous postgresData ?
tdp
tdpOP•4d ago
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)
Xiticks
Xiticks•4d ago
And in backups, do you have stuff?
tdp
tdpOP•4d ago
YEs, same story, created folder, copy pasted by hand and then rsynched back
Xiticks
Xiticks•4d ago
yeah, but you have "zip" fiiles in it right?
tdp
tdpOP•4d ago
No description
Xiticks
Xiticks•3d ago
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
tdp
tdpOP•3d ago
It's in the local network, so I have access to the root shell from the GUI
Xiticks
Xiticks•3d ago
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
tdp
tdpOP•3d ago
done
Xiticks
Xiticks•3d ago
Can you share the output of the ll command inside the shell?
tdp
tdpOP•3d ago
truenas_admin@truenas[/mnt/apps-pool/Apps/immich/pgData]$ ll
total 209
drwx------ 20 netdata 26 Sep 30 23:42 ./
drwxrwx--- 9 root 9 Sep 30 21:35 ../
-rwxrwx--- 1 netdata 3 Sep 30 21:50 PG_VERSION*
drwxrwx--- 7 netdata 7 Sep 30 21:50 base/
drwxrwx--- 2 netdata 63 Sep 30 22:55 global/
drwxrwx--- 2 netdata 2 Sep 30 21:50 pg_commit_ts/
drwxrwx--- 2 netdata 2 Sep 30 21:50 pg_dynshmem/
-rw------- 1 netdata 4821 Sep 30 21:50 pg_hba.conf
-rw------- 1 netdata 1636 Sep 30 21:50 pg_ident.conf
drwxrwx--- 4 netdata 5 Sep 30 23:42 pg_logical/
drwxrwx--- 4 netdata 4 Sep 30 21:50 pg_multixact/
drwxrwx--- 2 netdata 2 Sep 30 21:50 pg_notify/
drwxrwx--- 2 netdata 2 Sep 30 21:50 pg_replslot/
drwxrwx--- 2 netdata 2 Sep 30 21:50 pg_serial/
drwxrwx--- 2 netdata 2 Sep 30 21:50 pg_snapshots/
drwxrwx--- 2 netdata 3 Sep 30 23:42 pg_stat/
drwxrwx--- 2 netdata 2 Sep 30 21:50 pg_stat_tmp/
drwxrwx--- 2 netdata 3 Sep 30 21:50 pg_subtrans/
drwxrwx--- 2 netdata 2 Sep 30 21:50 pg_tblspc/
drwxrwx--- 2 netdata 2 Sep 30 21:50 pg_twophase/
drwxrwx--- 4 netdata 5 Sep 30 21:50 pg_vectors/
drwxrwx--- 3 netdata 12 Sep 30 21:59 pg_wal/
drwxrwx--- 2 netdata 3 Sep 30 21:50 pg_xact/
-rw------- 1 netdata 88 Sep 30 21:50 postgresql.auto.conf
-rw------- 1 netdata 29525 Sep 30 21:50 postgresql.conf
-rwxrwx--- 1 netdata 87 Sep 30 22:54 postmaster.opts*
truenas_admin@truenas[/mnt/apps-pool/Apps/immich/pgData]$
truenas_admin@truenas[/mnt/apps-pool/Apps/immich/pgData]$ ll
total 209
drwx------ 20 netdata 26 Sep 30 23:42 ./
drwxrwx--- 9 root 9 Sep 30 21:35 ../
-rwxrwx--- 1 netdata 3 Sep 30 21:50 PG_VERSION*
drwxrwx--- 7 netdata 7 Sep 30 21:50 base/
drwxrwx--- 2 netdata 63 Sep 30 22:55 global/
drwxrwx--- 2 netdata 2 Sep 30 21:50 pg_commit_ts/
drwxrwx--- 2 netdata 2 Sep 30 21:50 pg_dynshmem/
-rw------- 1 netdata 4821 Sep 30 21:50 pg_hba.conf
-rw------- 1 netdata 1636 Sep 30 21:50 pg_ident.conf
drwxrwx--- 4 netdata 5 Sep 30 23:42 pg_logical/
drwxrwx--- 4 netdata 4 Sep 30 21:50 pg_multixact/
drwxrwx--- 2 netdata 2 Sep 30 21:50 pg_notify/
drwxrwx--- 2 netdata 2 Sep 30 21:50 pg_replslot/
drwxrwx--- 2 netdata 2 Sep 30 21:50 pg_serial/
drwxrwx--- 2 netdata 2 Sep 30 21:50 pg_snapshots/
drwxrwx--- 2 netdata 3 Sep 30 23:42 pg_stat/
drwxrwx--- 2 netdata 2 Sep 30 21:50 pg_stat_tmp/
drwxrwx--- 2 netdata 3 Sep 30 21:50 pg_subtrans/
drwxrwx--- 2 netdata 2 Sep 30 21:50 pg_tblspc/
drwxrwx--- 2 netdata 2 Sep 30 21:50 pg_twophase/
drwxrwx--- 4 netdata 5 Sep 30 21:50 pg_vectors/
drwxrwx--- 3 netdata 12 Sep 30 21:59 pg_wal/
drwxrwx--- 2 netdata 3 Sep 30 21:50 pg_xact/
-rw------- 1 netdata 88 Sep 30 21:50 postgresql.auto.conf
-rw------- 1 netdata 29525 Sep 30 21:50 postgresql.conf
-rwxrwx--- 1 netdata 87 Sep 30 22:54 postmaster.opts*
truenas_admin@truenas[/mnt/apps-pool/Apps/immich/pgData]$
Xiticks
Xiticks•3d ago
well yeah, makes sense as you set a new user can you do rm -r * while still in pgData
tdp
tdpOP•3d ago
done
Xiticks
Xiticks•3d ago
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 ?
tdp
tdpOP•3d ago
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
Xiticks
Xiticks•3d ago
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
DB_SKIP_MIGRATIONS
DB_SKIP_MIGRATIONS
and value should be
true
true
tdp
tdpOP•3d ago
doen done*
Xiticks
Xiticks•3d ago
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
tdp
tdpOP•3d ago
you mean here ?
No description
Xiticks
Xiticks•3d ago
You said that encoded-video was corrupted, right? Yes
tdp
tdpOP•3d ago
mount or host to /data/library ?
Xiticks
Xiticks•3d ago
the mount path inside Immich is /data/internal_Immich_folder so mount
tdp
tdpOP•3d ago
more than corrupted, empty
Xiticks
Xiticks•3d ago
Host, well you keep the info where your library is Oh well, that is fine then 😄
tdp
tdpOP•3d ago
Done (like this)
No description
tdp
tdpOP•3d ago
I lost some snapshot idk how and deleted the dataset out of stress
Xiticks
Xiticks•3d ago
Well that's ok, you'll make Immich regenerate them So now, you can start Immich (It won't work yet, don't worry)
tdp
tdpOP•3d ago
it's looping deploying and running
Xiticks
Xiticks•3d ago
Normal It's in a state where the databse isn't initialised
gunzip --stdout "path/to/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 "path/to/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
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 ask
tdp
tdpOP•3d ago
I 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 sudo
Xiticks
Xiticks•3d ago
oh mb always forget that sudo su first (to "login" as root) then run the command
tdp
tdpOP•3d ago
done
Xiticks
Xiticks•3d ago
I suppose it output lines in the terminal?
tdp
tdpOP•3d ago
yes went full matrix
Xiticks
Xiticks•3d ago
If so, edit the immich app again, and remove the env variable
tdp
tdpOP•3d ago
done
Xiticks
Xiticks•3d ago
Restart Immich app And in theory, it should work Well we will double check that
tdp
tdpOP•3d ago
it's still looping deploying and runing :/ data/encoded-video is empty (no .immich)
Xiticks
Xiticks•3d ago
Oh yeah so cd into it from shell (into encoded-video) and do
touch .immich
touch .immich
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
tdp
tdpOP•3d ago
wowo seems to work
Xiticks
Xiticks•3d ago
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"
tdp
tdpOP•3d ago
yes aI can download i cannot understand what to do in the link
Xiticks
Xiticks•3d ago
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)
tdp
tdpOP•3d ago
i sent the job 1) Do I need to do something on my android immich app 2) can i delete che old config datasets?
Xiticks
Xiticks•3d ago
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
tdp
tdpOP•3d ago
It seems that the android app wants to re-upload everything
No description
Xiticks
Xiticks•3d ago
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
tdp
tdpOP•3d ago
:peepoAwesome:

Did you find this page helpful?