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.

lr_catalog_needs_repair
lr_unable_to_repair

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!

Technology in film

Next Article

Technology in film

2 Comments

Cancel

  1. And yet I couldn’t recover my catalog. It truncates it at just over 5GB while the original is about 5.5Gb. I am loosing something there. Thanks anyway this goes a bit further than LR trying to repair it by itself

  2. Works as advertised, but you do need to be fairly confident with a command-line. Thanks for posting this; it’s been a huge help.