DBRepair development

Hi-

How would I go about running this on Unraid as a scheduled task? I’ve tried running it in User Scripts plugin but get this error - Are you trying to run the tool from outside the container environment ?

After running the DBRepair Plex runs perfect for 5-7 days. It would be great to automate running the script.

Thanks, Dan

DBRepair runs very well as a scheduled task / cron job.

The syntax is simple. List the commands in sequence

DBRepair.sh stop auto start exit

Just that easy.

If you were to open a terminal session:

(This is close… sorry if not exact. doing it from memory/my unraid machine is turned off)

docker exec -it  <container_name>  bash DBRepair.sh stop auto start exit
1 Like

Awesome, thanks!

what would be the nicest timeframe to run it on auto?
once every three days?

As someone who has been using this tool stop automatic status start exit almost since it came out I would say it depends on the amount of content and the frequency you are adding/changing media on your plex server.

If you add very little content (couple of movies, few tv episodes and some music each week) I would say once every few months would be fine. Larger updates say once a month to once a week.

You will notice the more you run the tool the very small improvements in db size etc you will notice over time.

Myself, I use to run it once a week but now its monthly. BTW… it won’t cause any harm running it even once a day if that is what you decide but that would be overkill IMO.

2 Likes

thank you :slight_smile:

Hello,

I received a notification of a newer version of Plex. I stopped my Plex server, downloaded the new package, updated to the new version of Plex (from 1.40.1 to 1.40.2) and after starting Plex again, I have an XML error menu and plex no longer starts.

I looked everywhere. I tried the Plex SQLite method, which didn’t work. Then I found your github and followed the instructions and did an Automatic repair.

I have a QNAP server and running Plex as an app, not in a container.

Now after following the steps for Automatic repair, I try doing Step 7 - Start - Start PMS and it returns “Could not start PMS. Error Code: 1”

I also have a large library

Please help
DBRepair.log (2.8 KB)

It’s not an error but an expected behaviour when the DB is running migrations.

It’s been mentioned in the release notes too:

@Zodiak

Please be advised -

This is not Plex Media Server area

This is “Third Party” → “Apps & Tools” → “PlexDBRepair development”

Please remember to create new topics/threads in the "Plex Media Server’ forum with tag server-qnap

Taking into account a VERY large library, how long could it take? Also, what if this process just keeps going on and never appears to end? Thank you.

I am sorry, I don’t know things.

I was just told to reply here when I asked around for help :frowning:

@Zodiak

No harm - no fowl.

I’m only trying to help point you in the right direction so you can get the right help quicker for anything which might happen in the future

:slight_smile:

No clue since I don’t do beta versions. You may want to open a new thread, as advised, to see how long it’s taken for other people and for any help in case it’s stuck.

1 Like

So based on previous posts, this error while running an attempted repair means nothing can be done to repair, correct?

Runtime error near line 6097810: UNIQUE constraint failed: fts4_metadata_titles_icu_segdir.level, fts4_metadata_titles_icu_segdir.idx (19)
Runtime error near line 6097811: UNIQUE constraint failed: fts4_metadata_titles_icu_segdir.level, fts4_metadata_titles_icu_segdir.idx (19)
Runtime error near line 6097812: UNIQUE constraint failed: fts4_metadata_titles_icu_segdir.level, fts4_metadata_titles_icu_segdir.idx (19)
Runtime error near line 6097813: UNIQUE constraint failed: fts4_metadata_titles_icu_segdir.level, fts4_metadata_titles_icu_segdir.idx (19)
Runtime error near line 6097814: UNIQUE constraint failed: fts4_metadata_titles_icu_segdir.level, fts4_metadata_titles_icu_segdir.idx (19)
Runtime error near line 6097815: UNIQUE constraint failed: fts4_metadata_titles_icu_segdir.level, fts4_metadata_titles_icu_segdir.idx (19)
Runtime error near line 6097816: UNIQUE constraint failed: fts4_metadata_titles_icu_segdir.level, fts4_metadata_titles_icu_segdir.idx (19)
Runtime error near line 6097817: UNIQUE constraint failed: fts4_metadata_titles_icu_segdir.level, fts4_metadata_titles_icu_segdir.idx (19)
Runtime error near line 6097818: UNIQUE constraint failed: fts4_metadata_titles_icu_segdir.level, fts4_metadata_titles_icu_segdir.idx (19)
Runtime error near line 6097819: UNIQUE constraint failed: fts4_metadata_titles_icu_segdir.level, fts4_metadata_titles_icu_segdir.idx (19)
Runtime error near line 6097820: UNIQUE constraint failed: fts4_metadata_titles_icu_segdir.level, fts4_metadata_titles_icu_segdir.idx (19)
Runtime error near line 6097821: UNIQUE constraint failed: fts4_metadata_titles_icu_segdir.level, fts4_metadata_titles_icu_segdir.idx (19)
Error 1 from Plex SQLite while importing from ‘./dbtmp/library.plexapp.sql-2024-04-22_03.06.11’

Because for some reason my newest database backup that plex generated is from 12/2022 so if my only option is replace that really sucks

Edited to add some extra error lines

This doesn’t just happen out of the blue.

I don’t think it’s out of the blue. I’m saying databases stopped generating then so I’m assuming I’ve been working with a broken database since then but never saw anything to indicate that

@cmac1027

Confirm please?

Plex has not created any database backups since 2022 ?

If this is true then the database is indeed damaged and PMS can’t deal with it.
Your choices are to IGNORE (menu option) the constraint errors and try to continue (scanning files and force refreshing metadata) for all library sections.

Constraint errors indicate duplication of data. When IGNORED, those duplicates are dropped without any other consideration. You may get a fully intact DB but may not. There will be some holes in the data (which can be filled in again).

In all cases, when done, Plex will be able to generate backups.

Thanks for the reply. Correct, no database backups since 2022. Luckily, following the manual steps here: Reddit - Dive into anything I was able to successfully repair the database and now your tool also reports it is healthy again. I will be watching much more closely to make sure backups are being created regularly. Also, if there is a next time (please don’t let there be a next time) I will know to try the ignore option.

Thanks again

@cmac1027

Those commands are what my tool does.

I have the scripting automation built in to confirm the database is valid which includes the CONSTRAINT checking/reporting.

Because CONSTRAINT errors can happen when recovering or importing watch history, I’ve added the “ignore” (ignore CONSTRAINT errors) command.

My development plans are be more intelligent when repairing and have the tool deal with this on its own when in 'automatic" mode.