I have a problem with a LR catalog.
I am openening it, can see my last imported photos and then i have an error: LR encounted an error when reading a catalog file and need to quit. Then LR is shutting down and then trying to repair the catalog with no result.
Unfortunatly I have no backups. So how can i repair my catalog? It contains photoshoots for 2 years.
The only advice I have seen is to open a new catalog and then try importing the corrupted catalog into it. I am quite skeptical that this ever works, but who knows. After that, I think you're out of luck.
Make regular and automated backups of your catalog file and photos from this point forward. No excuses.
Thank you for the piece of advice, but how can i open an older catalog in a newer one?
any other ideas?
Here is the error:
As far a I know, this is the end of the trail. The catalog cannot be fixed.
I can't say whether this will work for you of if you are willing to give it a try... comments indicate that others have been successful repairing a corrupt catalog using this method.
Thanks! I will try!
Import 'from another Catalog' (into a fresh one) did do the trick for me - once, the only time, when my catalog was not directly openable - although LR has also asked for a couple of catalog integrity fixes over the years.
Do you have backups for your catalog? If you don't know, search all your drives using the term "backup"
The backup folders that Lightroom creates look like this:
If you find those, pick the most recent one and open the folder. The file inside will be a .lrcat.zip file you will have to unzip. The unzipped file will end with .lrcat. Open that unzipped file in LR.
Unfortunatly, I haven't
I'have found the solution: Corrupt Catalog Issues
- Download SQLite, put it in a folder, make a COPY of your lrcat file and put it in the folder.
- run sqlite3 "INSERT_CATALOG_NAME_HERE.lrcat" .dump > Temp.sql
- run sqlite3 -init Temp.sql NEW_CATALOG_NAME.lrcat
- This is where the existing online tutorials break down, if there are errors, it will not dump out the new database file! You can't just tell sqlite to dump a corrupt catalog to corrupt sql and back to a corrupt catalog...you're not fixing anything.
- Note the errors that the last command generates. It will give you line numbers for the errors. For me, I was getting "UNIQUE constraint failed" errors and "no such table" errors for the table sqlite_stat4 on a couple hundred lines or so.
- Open the Temp.sql file in an editor. Notepad will work but it's way easier to deal with line numbers in something like Notepad++.
- Remove the exact lines which are generating errors and only those lines. As you are working in the file, you may need to be patient with your editor if the file is large. Jumping around, deleting lines, saving, may all take some time to complete...just wait for notepad++ to do its thing and unfreeze as you're working.
- If you try to use the file at this point, it won't work! it will generate a 0 byte catalog (At first I had this problem). The reason for this is that SQLite writes "ROLLBACK;" as the last line in the file due to the errors it encountered during the dump process. See here: sqlite - Sqlite3 recreates empty database from dump file - Stack Overflow . What you need to do is change that last line to say "COMMIT;" to commit the changes instead of rolling back.
- Now save the file...let's use TempBadLinesRemoved.sql and exit notepad++ or your preferred editor.
- run sqlite3 -init TempBadLinesRemoved.sql NEW_CATALOG_NAME.lrcat
- for me, the command completed and left me at the sqlite> prompt. Just type .quit to exit sqlite
- Open the catalog in lightroom and it should work.
I am so happy! thank you very much! 🙂
I'm trying to follow your steps but I noticed that the UNIQUE constant failed errors lines in my case are in the range of milions (i.e. Error: near line 1121903: UNIQUE constraint failed: Adobe_imageDevelopSettings.id_local) instead when I open the .sql file are in the range of thousands.
Thanks in advance!
Despite the errors you should be able to open the newly created catalog and it should run without problems. Can you confirm?
Oh my God! Dude. This was a lifesaver for me. Recovered my catalog successfully after getting rid of few UNIQUE CONSTRAINT errors and putting COMMIT at the end.
Using Lightroom Classic 10.0 (2020)
Can you help me in one thing please? do you have messenger or facebook that I can sen you a video?
Thank you very much for helping me saving 13000 of processed files!
It might be useful to know, that the files sqlite3.dll, sqlite3.def and sqlite3.exe together with the corrupted file are needed to be in the same directory.
OMG Polinab You're genius. Thank you Thank you Thank you. Just saved a bunch of wedding pictures. My next move is: Back-up.
Hello! Can you help? In the last part "Now save the file...let's use TempBadLinesRemoved.sql and exit notepad++ or your preferred editor.", how did you do it? Dont undertand it, could you sent me a video or you can´t right now?
And the link its not working... 😞
Thanks mate. Worked for me on LR Classic 2022.
I did notice that some of my collection information was missing but no big deal. Simple case of re-adding it from the library. All my flags were still there so it was a breeze. Cheers