5

While I was importing photos from a SD card in Shotwell, my laptop has crashed (shutdown because of over-heating). Now, I can no longer launch Shotwell:

$ shotwell
**
ERROR:x86_64-linux-gnu/db/VersionTable.c:104:version_table_construct: assertion failed: (res == SQLITE_OK)

If I move the .db file ~/.shotwell/data/photo.db elsewhere so it is no longer present (but backed-up), shotwell will launch, but will rebuild its library, which will be empty. I can re-import the folders shotwell creates, but I lose nearly all meta-data (most importantly the "folders", or events, and their main picture)

Is there a way to repair/rebuild/restore photo.db? How can I see what's inside? how bad it's damaged?

Or is there another way to get back my events and imports?

RobotHumans
  • 30,112

3 Answers3

8

Shotwell's database can be corrupted due to kernel panics and loss of power.

With Shotwell 0.10 or above, the database is automatically backed up every time the program exits; in the worst case, you'd end up losing any work since you started the program.

Unfortunately, older versions of Shotwell don't have this feature and it's unlikely that you can recover from a corrupted database.

MrEricSir
  • 1,266
3

You can find the backup database in your .shotwell folder in "home". There will be a photo.db.bak.

Just rename it to photo.db and delete the corrupt old "photo.db" and you should be fine again.

2

You can check the integrity of your database with the following command:

$ sqlite3 photo.db
SQLite version 3.7.4
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> pragma integrity_check;
ok

If it reports an error, you may be able to recover the contents by dumping the data and restoring it into a new database:

$ echo .dump | sqlite3 photo.db > photo_dump.sql
$ sqlite3 new_photo.db < photo_dump.sql

Back up the original database and then move the new one into place and see how things go.