Tag Archives: corrupt

How to recover from a corrupt Lightroom Catalog

How to recover from a corrupt Lightroom Catalog

… once and for all.

If you are a photographer that uses Lightroom you might have encountered a catalog problem. Sometimes they just clear up by themselves, but it may occur that you lose some of your precious work along the way.

Lightroom Catalog is corrupt

Lightroom Catalog is corrupt

The first thing you should try upon encounter of a message like this one above, is to delete the .lock file. Together with the catalog (.lrcat) you should find .lrcat-journal, .lrdata and .lock files. Well, delete or change the extension of the latter.

Screen Shot 2015-08-04 at 13.39.49

If this does not resolve the problem, and instead you’re more f**** than before, then this is what happened to me and you’re on the right post.


Let’s play the magic

As it turns out, Lightroom catalogs are simply sql tables underneath. So by extracting it into a .sql file and recreating a new catalog from it will, in fact, solve all our problems with no data loss. To do this, use the command line tool sqlite3.

** If you don’t have this command, probably you need to download the command line utilities that fit your operating system from SQLite’s home page (http://www.sqlite.org).

  1. Open a terminal window
  2. Dump the .sql info:
    $ echo .dump | ./sqlite3 ~/catalog.lrcat > ~/catalog.sql
  3. Recreate a new catalog from it:
    $ ./sqlite3 -init ~/catalog.sql ~/new_catalog.lrcat

NOTE: Try sqlite3 (without ./) if your sql utility was already installed in your system root.
NOTE 2: Also, ~/ stands for your home path. Replace it with the path to the catalog as seen from the folder you’re in at the moment.

So simple, yet so powerful. I don’t understand why Lightroom’s automatic repair system won’t try doing this!