Database corruption Unable to get a backup or optimize

Running Plex 1.15.6.1079 on Ubuntu 18.04 LTS
Recently I noticed I had no backups on my DB. I tried to check the DB for issues and I am getting this error

sqlite3 com.plexapp.plugins.library.db "DROP index 'index_title_sort_naturalsort'"
Error: no such index: index_title_sort_naturalsort

So after that I try the following commands,

sqlite3 com.plexapp.plugins.library.db .dump > dump.sql
grep -v "naturalsort" dump.sql > newdump.sql
sqlite3 com.plexapp.plugins.library.db < newdump.sql

And I am met with an uncountable amount of the following

Error: near line 46072: UNIQUE constraint failed: media_parts.id
Error: near line 46073: UNIQUE constraint failed: media_parts.id
Error: near line 46074: UNIQUE constraint failed: media_parts.id
Error: near line 46075: UNIQUE constraint failed: media_parts.id
Error: near line 46076: UNIQUE constraint failed: media_parts.id
Error: near line 46077: UNIQUE constraint failed: media_parts.id

At this point I am not sure what to try next. I would prefer not to rebuild. my DB is nearly 1.5GB

You’ve got an issue where an ID that is suppose to be unique is not unique and being used my more than 1 item. You’re gonna have to manually find these entries, decide which are wrong, and delete them. If you are not familiar with SQL, I would not recommend trying this yourself.

I am a little familiar and ok with trying it on a backup of the DB. If you can point me in a general direction that would be great.

Look in the table media_parts. The field ID is meant to be unique but you have duplicates somehow. Run a query to find these duplicates then remove them.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.