Database is broken (i think) please help

I removed a directory containing several thousand images from a watched library path, I expected that a rescan would be all that was needed as far as plex was concerned.

However, My plex is not working at all anymore, i can load the main page and see content but not play back anything. Every time I try to play a video or an image, it just times out.

I have tried to manual rescan but nothing happens, as if it is not actually scanning. I have also tried to optimise the data base but that does not seem to actually do anything either.

I am out of ideas, I don´t want to wipe it and reinstall as I have manually put in a huge amount of metatdata that will have to be manually entered again and this something that I want to avoid.

Is there any hope for this?

Version 1.9.7.4460 running on Linux Mint 18.2

I have just tried this - https://support.plex.tv/hc/en-us/articles/202485658-Restore-a-Database-Backed-Up-via-Scheduled-Tasks-

I am optimizing now.

follow the general procedure from here https://support.plex.tv/hc/en-us/articles/201100678-Repair-a-Corrupt-Database

Don’t try to ‘repair’ the existing.

  1. Stop PMS
  2. Rename the existing to .old
  3. Rename the backup to be the primary .db
  4. Run the PRAGMA check to verify validity
  5. Verify ownership of the file is still plex:plex and permissions valid (644)
  6. Start PMS
  7. Rescan all library files to update media (resync the DB)

nope, as soon as i rescan and notices that all those files are missing, the whole thing stops working, I can use the UI but cannot playback anything. I´ll try to remove the library and see if that helps.

ok I eventually managed to delete the library after having to stop and start the service several times. It seems be ok now, i´m just adding the library back in again so will see, it will probably take a while, it´s a big library.

Thanks for everyones help :wink: maybe this will help somebody else at some point.

You might want to have it “Optimize Database” manually a few times while rebuilding. It does help keep the database as fast as possible.

Thank you @ChuckPA, As you may have noticed, I posted about, then fixed before you got to this but basically did what you suggested it anyway so I guess I was on the right track. It seems ok now.

In case anyone else interested.

I restored an older database (as easy as stopping plex, deleting the current DB then putting renaming a backup file, then starting plex again.)

Then I removed the problem library.

Next I optimised the Database

Then added the Library back in again.

I only lost a few watched statuses during the process, nothing significant. It shows how important it is to have that ¨backup database¨ checkbox enabled. Without that, I would have been in serious trouble.

unfortunately, YOU are not able to chose a path fr the database to be backed up to and you can only choose a schedule if every 3 days or not at all but it is better than nothing.

I suppose that a backup schedule could be created in a script where you simply stop plex, take a copy of the database file and then start plex again, you can do this as often as you want. On a busy server, it may pay to have daily backups. I have daily updates to mine so would prefer this.

“unfortunately, YOU are not able to chose a path fr the database to be backed up to and you can only choose a schedule if every 3 days or not at all but it is better than nothing.”

You can under the Scheduled tasks area.

Not on my server you cant, It only has a checkbox to Backup database every three days

@MattTwinkleToes said:
Not on my server you cant, It only has a checkbox to Backup database every three days

yes thanks but i do not have that option on mine, it´s not there.

Don´t worry about it though, I have more pressing issues with my server at the moment :slight_smile: