DBRepair development

While you’re here:

  1. I got the schema code working right now.

  2. Fixed the last ‘gotcha’ I had in it getting confused about ‘source-of-truth’ resolving. Turns out to be how Plex manages Main vs Blobs DBs.

  3. Taking today off to play my game and relax

  4. Added two much-needed command line options
    -n == No Commit (same as the Linux ‘dry run’ flag)
    -f == Force even when “Check” fails miserably.

  5. One last round of testing and then DBRepair will have what I’ve always wanted.
    – Ability to verify its schemas against itself and repair damage
    – Ability to fallback to known-good data when the world crumbles.

This will be a big update

I honestly don’t understand why you’re campaigning against this. Just let Chuck decide. Sheesh.

The constant “I don’t think anyone else will want it” is less than useless. Just say “I don’t think it’s useful” and move along.

A more targeted approach would be something like this…

"/usr/lib/plexmediaserver/Plex Media Server" --sqlite com.plexapp.plugins.library.db
SELECT id, name from accounts;

This will give you the list of accounts in your db including the id and the name. Find the one you want to delete from your watch history and take note of its id. Then run …

SELECT * FROM metadata_item_views WHERE account_id = 123456789;
DELETE FROM metadata_item_views WHERE account_id = 123456789;
VACUUM;
.quit

123456789 is the account id you want to change that based on your user. Command 1) will list the records, 2) will delete them if your happy and 3) and 4) are just db maintenance after deleting the records.

One thing to beware of is “Sync Your Watch State and Ratings” as these might come back if the user has that enabled on their account. Might be worth deleting the account from your accounts table.

Well, 3 things here:

  1. You are right
  2. Second time was just telling Chuck what I said to you, in case he missed it
  3. What goes into Chuck’s tool is Chuck’s call, and his call only

Chuck might want to get it working and 100% solid before adding a bunch of new bells & whistles

:thinking:

@dokuro

Your SQL is wrong IMHO!

You are not deleting the entire table, but only records for a single user, yet you reset the auto increment counter back to 0, meaning a clash will happen when new records are added

I wasn’t asking for “a bunch of bells and whistles.” I just take exception to someone actively campaigning against it. Sheesh, never mind. Consider me out of this thread.

Good point, I’ll update.

You could also remove Watch History with API calls if you don’t want stop PMS in order to touch the DB.

Not watch history, but play history. They are distinct things in PMS.

But your point is taken.

@pshanew

Don’t get upset.

Folks don’t know how I’m getting hammered for new features.

Sorry my words sounded harsh. didn’t mean that way.

Here’s what’s coming as soon as QA guys bless it.

DBRepair Release Notes

v0.1999.08

  * All Platforms   - Corrects database owner and permissions not restored after work completed.
                    - Corrects fatal sql bug which forced  v0.1999.06 removal 

  * DB Checks       - Checking databases now goes deep on initial check to find anything broken 
                      or missing.  This information is used to guide the rebuild and to inform.
                      Previously invisible minor damage will surface and be repaired.

  * Schemas         - Schema repairs from own backups begining this version.
                      DBRepair now uses its own backups & known schemas to ensure accurate rebuild.  
                      This is still in development so if DBRepair can find nothing to use,  
                      it will tell you so and exit.   The complete fallback will be DBRepair.sh style.

  * New Command     - 'expunge' removes view history left behind by
                      non-existent user accounts.

  * Program flow    - Minor flow control flag corrections. Repair will now
                      fully halt on hard unrecoverable errors (forces REPLACE)

  * Integrity Check - Finds missing indexes / triggers during check. 
                      Corrects during repair

  * Command line    - Now supports two additional command line options

                      Don't commit changes to live DBs:      -n  or  --nocommit  (Linux's 'dry run' option)
                      Force DBRepair when disasters occur:   -f  or  --force

  * User Manual     - Realized a "User Manual" will be needed for DBRepair soon.
                      LOL
 

EDIT: This build of DBRepair has direct support of PMS 1.40.0 → 1.43.4 built in.

There was no upset my friend. I’m really sorry if I came across way .

Please just keep doing what you’re doing. This community is better for your efforts.

Just spent a while troubleshooting plex server that wont work on my mac only to discover the DBRepair tool that might save the day is down for maintenance. I kept trying to troubleshoot the DBRepair.sh tool only to discover it was 0 bytes and then read the github further. Was just checking here to see if there was a timeline for when it might be back up?

You can get it here:

ALL:

It’s taken a fair amount of effort but it looks like we’re ready for the next round.

I have extended the expiration to 14 days (instead of 7) to allow deeper testing.

You will now find DBRepair fully understands/supports PMS 1.40.0 → 1.43.4
I’ll finish the resolution of “what if” before 1.43.5 (or higher) is released.

Please read the ReleaseNotes in the ZIP file.

Root / Admistrator privileges must be active upon invocation - except macOS

Your feedback, Pro or Con, is invited

For your consideration: DBRepair v0.1999.08

Is the source code available for us to view?

@SwiftPanda16

No, the source is not yet available.

Development is still in progress.

@ChuckPa I downloaded DBRepair v0.1999.08 and unpacked it to the Databases folder. Starting DBRepair.exe in an elevated cmd instantly gives me an error message:

C:\Users\tobia\AppData\Local\Plex Media Server\Plug-in Support\Databases>DBRepair.exe
ERROR: Cannot open Main DB to determine its migration key.
Unhandled edge case encountered. Development in progress. Please contact @ChuckPa
ERROR: Unable to initialise DBRepair. Aborting.

PMS is version 1.43.4.10903 and is not running. Host is a Windows 10 machine.

Are there any logs?

If it managed to create a log, it should be present in the database directory and is named DBRepair.log

So the tool is not even able to create a log on my machine. :smiley: