DBRepair development

Hey there,

Versus the past versions, the addition of the ‘automatic’ mode is much better I think, less easy for people to get confused and make the steps in the wrong order. Plus for me, the database is 1.7gb so takes quite some time between steps to do manually.

The only issue I have found is that the new produced database files are set to ‘read only’ by default, so I need to manually change that with CHMOD after running the tool. I don’t have a problem with command line in Windows but always need to Google how to do things in Linux as I would only do this type of maintenance a few times per year. I am not sure if that permissions issue is coming from the Docker setup, or the tool itself.

I think the tool is critical based on the decision to use this “internal” version of SQLite in Plex since some time, which makes such database tasks prohibitively difficult for normal users (perhaps not such a bad thing :-)).

Thanks for the work, most appreciated here…

Cheers,

-jj-

Hi ! Hi have a problem with repair function, always same problem:

Exporting current databases using timestamp: 2023-03-15_12.26.29
Exporting Main DB
Exporting Blobs DB
Successfully exported the main and blobs databases.  Proceeding to import into new databases.
Importing Main DB.
Importing Blobs DB.
Runtime error near line 11251: UNIQUE constraint failed: blobs.linked_type, blobs.linked_id, blobs.blob_type (19)
Error 1 from Plex SQLite while importing from './dbtmp/blobs.plexapp.sql-2023-03-15_12.26.29'
Cannot continue.

Do you have an idea ? I am in a container already stopped

@sam37120

That’s a very badly busted database.

Did you try to replace with a backup?

Did the tool itself handle the error and stay running ? (don’t want a tool failure)

The next phase of my plans are to automate “Repair contraint failures → Replace DB”

Regarding this, I use the default UMASK of the user who runs the tool (root or the plex-user UID)

Can you show me the directory listing and what your default umask is?

If it helps to force RW (644) for $Owner, that’s easily done.

Here is the output from the ‘ls -la’ command, I hope it is enough information:-

> total 15340600
> drwxrwxrwx 1    777 users       4096 Mar 16 03:38 .
> drwxrwxrwx 1 nobody users         96 Jun 18  2020 ..
> -rwxrwxrwx 1    777 users  865316864 Mar 16 02:11 com.plexapp.dlna.db
> -rwxrwxrwx 1 nobody users    1474560 Mar 16 02:13 com.plexapp.dlna.db-shm
> -rwxrwxrwx 1 nobody users  750214976 Mar 16 02:13 com.plexapp.dlna.db-wal
> -rw-r--r-- 1 root   root  1744887808 Mar 16 03:11 com.plexapp.plugins.library.blobs.db
> -rwxrwxrwx 1 nobody users 1707716608 Mar  6 04:18 com.plexapp.plugins.library.blobs.db-2023-03-06
> -rwxrwxrwx 1 nobody users 1711235072 Mar  9 04:19 com.plexapp.plugins.library.blobs.db-2023-03-09
> -rwxrwxrwx 1 nobody users 1732935680 Mar 12 04:18 com.plexapp.plugins.library.blobs.db-2023-03-12
> -rwxrwxrwx 1 nobody users 1744838656 Mar 15 04:13 com.plexapp.plugins.library.blobs.db-2023-03-15
> -rw-r--r-- 1 root   root  1080737792 Mar 16 03:09 com.plexapp.plugins.library.db
> -rwxrwxrwx 1 nobody users 1095766016 Mar  6 04:11 com.plexapp.plugins.library.db-2023-03-06
> -rwxrwxrwx 1 nobody users 1102061568 Mar  9 04:12 com.plexapp.plugins.library.db-2023-03-09
> -rwxrwxrwx 1 nobody users 1085530112 Mar 12 04:11 com.plexapp.plugins.library.db-2023-03-12
> -rwxrwxrwx 1 nobody users 1085579264 Mar 15 04:07 com.plexapp.plugins.library.db-2023-03-15
> -rwxrwxrwx 1 root   root        6621 Mar 16 03:12 DBRepair.log
> drwxrwxrwx 1 root   root        4096 Mar 16 03:11 dbtmp
> drwxrwxrwx 1 nobody users         79 Mar 14 06:14 Music Analysis 14

Cheers,

-jj-

@jj666

I found it. Nasty little :bug:

v1.0.1 has been published

4 Likes

Ok thanks guys ! I replace backup it’s works for now, no problem with your incredible tools now :wink:
Yeah it would be a good improvement !

6 - ‘reindex’ - Rebuild database database indexes

Minor typo ‘database database’ in the help text.

Ran a ‘check’, ‘repair’, and ‘reindex’ and noticed an INCREASE in the size of my Blob DB from 82MB to 92MB. Is this normal/expected?

2023-03-18 20.41.10 - ============================================================
2023-03-18 20.41.10 - Session start: Host is Docker
2023-03-18 20.41.23 - Stop    - PASS
2023-03-18 20.44.34 - Check   - Check com.plexapp.plugins.library.db - PASS
2023-03-18 20.45.28 - Check   - Check com.plexapp.plugins.library.blobs.db - PASS
2023-03-18 20.45.28 - Check   - PASS
2023-03-18 20.50.54 - Exit    - Retain temp files.
2023-03-18 20.50.54 - Session end. Sat Mar 18 20:50:54 CDT 2023
2023-03-18 20.50.54 - ============================================================
2023-03-18 21.04.46 - ============================================================
2023-03-18 21.04.46 - Session start: Host is Docker
2023-03-18 21.06.32 - Repair  - Export databases - PASS
2023-03-18 21.08.38 - Repair  - Import - PASS
2023-03-18 21.08.58 - Repair  - Verify main database - PASS (Size: 363MB/342MB).
2023-03-18 21.08.58 - Repair  - Verify blobs database - PASS (Size: 82MB/92MB).
2023-03-18 21.08.58 - Repair  - Move files - PASS
2023-03-18 21.08.58 - Repair  - PASS
2023-03-18 21.11.07 - Check   - PASS
2023-03-18 21.11.08 - Reindex - MakeBackup com.plexapp.plugins.library.db - PASS
2023-03-18 21.11.08 - Reindex - MakeBackup com.plexapp.plugins.library.blobs.db - PASS
2023-03-18 21.11.08 - Reindex - MakeBackup - PASS
2023-03-18 21.11.50 - Reindex - Reindex: com.plexapp.plugins.library.db - PASS
2023-03-18 21.11.51 - Reindex - Reindex: com.plexapp.plugins.library.blobs.db - PASS
2023-03-18 21.11.51 - Reindex - PASS
2023-03-18 21.11.51 - Reindex - PASS
2023-03-18 21.12.42 - Exit    - Retain temp files.
2023-03-18 21.12.42 - Session end. Sat Mar 18 21:12:42 CDT 2023
2023-03-18 21.12.42 - ============================================================

Yes, that can happen.

What it shows us is that somewhere along the way, one of the Plex updates, where it updates the database schema, didn’t update correctly.

What you have now is a properly created database image from the ‘current’ schema PMS has defined.

Did you notice, you can run “auto” ?

If your container is supported for stop/start then

DBRepair.sh stop auto start exit

would have done it all for you

Meanwhile, as I torment the Windows version of Plex, I’m periodically running the Windows.bat version of this. It’s working well, I think, though I’m now not sure which version I’m running!

I see it. fixing now.

I fix one thing, I break the previous. Got it now

Not sure its an actually issue :slight_smile:

This stuff Output "Unexpected EOF / End of command line options, Exiting" is getting outputted but you could be adding stuff to the tool so looks like a error catch condition which is why I deleted previous post.

DBrepair.tar (60 KB)

Here… try this. fixed

[/tmp] # ./DBRepair.sh  stop auto start
 
 
 
      Plex Media Server Database Repair Utility (QNAP)
                       Version v1.0.3
 
 
[2023-03-29 04.06.20] Stopping PMS.
[2023-03-29 04.06.20] Stopped PMS.
 
[2023-03-29 04.06.20] Automatic Check,Repair,Index started.
[2023-03-29 04.06.20] 
[2023-03-29 04.06.20] Checking the PMS databases
[2023-03-29 04.06.26] Check complete.  PMS main database is OK.
[2023-03-29 04.06.26] Check complete.  PMS blobs database is OK.
[2023-03-29 04.06.26] 
[2023-03-29 04.06.26] Exporting current databases using timestamp: 2023-03-29_04.06.20
[2023-03-29 04.06.26] Exporting Main DB
[2023-03-29 04.06.37] Exporting Blobs DB
[2023-03-29 04.06.41] Successfully exported the main and blobs databases.  Proceeding to import into new databases.
[2023-03-29 04.06.41] Importing Main DB.
[2023-03-29 04.07.13] Importing Blobs DB.
[2023-03-29 04.07.13] Successfully imported databases.
[2023-03-29 04.07.13] Verifying databases integrity after importing.
[2023-03-29 04.07.19] Verification complete.  PMS main database is OK.
[2023-03-29 04.07.20] Verification complete.  PMS blobs database is OK.
[2023-03-29 04.07.20] Saving current databases with '-BACKUP-2023-03-29_04.06.20'
[2023-03-29 04.07.20] Making repaired databases active
[2023-03-29 04.07.20] Repair complete. Please check your library settings and contents for completeness.
[2023-03-29 04.07.20] Recommend:  Scan Files and Refresh all metadata for each library section.
[2023-03-29 04.07.20] 
[2023-03-29 04.07.20] Backing up of databases
[2023-03-29 04.07.20] Backup current databases with '-BACKUP-2023-03-29_04.07.20' timestamp.
[2023-03-29 04.07.20] Reindexing main database
[2023-03-29 04.07.26] Reindexing main database successful.
[2023-03-29 04.07.26] Reindexing blobs database
[2023-03-29 04.07.26] Reindexing blobs database successful.
[2023-03-29 04.07.26] Reindex complete.
[2023-03-29 04.07.26] Automatic Check, Repair/optimize, & Index successful.
 
[2023-03-29 04.07.26] Starting PMS.
[2023-03-29 04.07.32] Started PMS
[2023-03-29 04.07.32] Unexpected EOF / End of command line options,  Exiting
 
[/tmp] # 
1 Like

V1.0.3 repaired and re-released

Thank you

3 Likes

Re-downloaded from github and looks good, thank you Chuck.

Thank you for catching that.

I wish I’d caught that in the rewrite. I feel like I’ve taken several steps backward. :frowning:

Happy to help. It’s easy to become blind to what your working on every day. Wasn’t a serious failure anyhow.

I appreciate the critical eye . It seems the tool is becoming more popular than I ever expected.

3 Likes

The way this is going you’ll end up having to write an app. Uh oh.

You know what, though, I’d be delighted if there was a way to incorporate this directly in either Plex or Plex Dash.