DBRepair development

Tony,

are you suggesting to show the Environment variable value as part of the menu?

I ask because I don’t look at the ENV variable until it’s used.

Q: If I had several different user-controllable options, would it make sense to show all of their values in the menu?

Damn spammers. (REMOVED)

what permissions does the new user need? i haven’t set up a new user in years and dont want to give this new user more permissions than it needs. or should i not create a new user and just use my username?

Yes, I was suggesting showing the Environment variable value as part of the menu.
You could read the env into a variable in the script and then use it in the menu before it’s used.
But this is not really necessary, just a minor suggestion.

I wasn’t aware of other user-controllable options, but, yes, I think it would make sense to include in the menu. A lot of users don’t RTFM :smile:

Hi @ChuckPa

It seems that I did not follow the development of this tool not close enough.

I found a very interesting command line parameter, but I wasn’t able to find a detailed description of what exactly can be done:

IMPO(rt)     - Import viewstate / watch history from another database
  • Does this have anything to do with Plex Viewstate sync feature that I disabled or does it do an “offline” view state / watch history import froma database from another source server?
  • Does the source server have to be active or can the view state / watch history also grab it from any database backup? Or can the view state / watch history also be exported into any “portable” format / file in order to be re-imported after a hard drive crash (ie. old server no longer available)?
  • Does that work for servers holding libraries which are not “upgraded” (still using classic - “legacy” - PMS movie and TV show agents)?

And just out of interest: How is view state saved internally? Classic libaries are not using the unique Plex identifier, for example.

@rossinior

It’s in the README but not a lot to say beyond the description.

  1. It imports viewstate (watch history) information from another PMS database (.db) file which you point it at. (Server shutdown & the DB file is not actively being used)

  2. Because of how it works (raw table import), it’s possible to import watch history for media you don’t have. This is why caution is advised. There are some checks after import but it’s not possible to catch all issues without PMS running.

  3. It was developed before Plex “cloud sync”.

  4. If you import watch history which was not previously sync’d to PMS cloud, it will sync it to the cloud during next sync cycle.

  5. Watch history uses metadata_item_settings in the DB which has always existed.

Thank you very much. This sounds like a nice feature.

I am not using the “sync to cloud feature” and I don’t want to.
Is there a way to avoid this after import?

Is there anything you can say about libraries’ view state using still the legacy agents?

Cloud sync - View state saving is an account feature you turn on/off as you wish.

Settings - Account

Regardless of agent, view state is saved in the same database table.
This is what does or does not get sync’d.

1 Like

Hello!
My Plex database is corrupted and I’m trying to use DPRepair.
When I run 3, I get this.

*Checking the PMS databases*
*Check complete.  PMS main database is damaged.*
*Check complete.  PMS blobs database is OK.*

When I run option 2 or 5 I get what you see below.
Any ideas? :grimacing:
Thank you!

Option 2

*Automatic Check,Repair,Index started.*

*Checking the PMS databases*
*Check complete.  PMS main database is damaged.*
*Check complete.  PMS blobs database is OK.*

*Exporting current databases using timestamp: 2024-02-08_15.16.31*
*Exporting Main DB*
*Error: cannot open "./dbtmp/library.plexapp.sql-2024-02-08_15.16.31"*
*Error: cannot write to "./dbtmp/library.plexapp.sql-2024-02-08_15.16.31"*
*Error 1 from Plex SQLite while exporting com.plexapp.plugins.library.db*
*Could not successfully export the main database to repair it.  Please try restoring a backup.*
*Repair failed. Automatic mode cannot continue. Please repair with individual commands*

Option 5

Exporting current databases using timestamp: 2024-02-08_15.06.11
Exporting Main DB
Exporting Blobs DB
Successfully exported the main and blobs databases.  Proceeding to import into new databases.
Importing Main DB.
Parse error near line 1: no such table: schema_migrations
Parse error near line 2: no such table: schema_migrations
Parse error near line 3: no such table: schema_migrations
Parse error near line 4: no such table: schema_migrations
Parse error near line 5: no such table: schema_migrations
Parse error near line 6: no such table: schema_migrations
(This kept repeating till it hit 283 and then stops)

ALL STOP –

The tool cannot write to the temporary directory.
Are you running as root / the correct user ID?

I’m afraid I don’t know what you mean by “the temporary directory”. Can you please elaborate?
I’ve put the .sh on the root directory of the container.

I run Plex in Docker on Unraid. On Unraid, Docker runs directly on the hypervisor.
I’m running the command in the Console for the Plex Container.
When I run whoami on the container it says I’m root.

I also forgot to mention this, but I stopped Plex via command 1 before running the other commands.

@JohnnyPotato

Are you running DOCKER_MODS?

The only other issue I’ve had with this was an error was caused by that theme.
Here is the closing message from that user.

Well I think I may have lead us down an endless rabbit hole. Also thanks for all your time and help on this!

Testing today I created a new plex docker container with same image and pointed it to my old /pms location with all contents still there. Launched and tested script and low and behold it launched!
So go and begin adding the extra paths, variables for hardware transcoding etc.

I also added back in variables back in for Theme-Park (DOCKER_MODS) and my TP_THEME and tested again and boom back to the ERROR: Cannot write to Databases directory. Insufficient privilege. Removed the DOCKER_MODS line and it runs again.

So something about that the script didn’t like. I’ve since got both the Theme working again and the script also running by altering the DOCKER_MODS value to match Setup - theme.park Docs

Apologies for what ended up being a bit of a wild goose chase and thanks once again for all your time and support on the issue!

I don’t think so. I’m honestly not sure what that is.

@JohnnyPotato

The .dbtmp directory is created directly underneath the Databases directory.

I have no idea what could be blocking at this point.

Whose image are you using in the container ?

ALL:

I’ve received a report that PMS on MacOS uses $HOME/Library/Caches/Plex Media Server

To support MacOS and linux, I’ve augmented the tool to support this.

Testing still shows there’s a problem in that I haven’t named the path correctly.

Might someone be able to show me my error?

Checking …

  • I was able to cd into the expected directory in a terminal, the one where you said
    CacheDir="$HOME/Library/Caches/PlexMediaServer/PhotoTranscoder"
    Looks good for now. I’ll run it and see what happens.
  • The prune option’s find command works where you make a FileCount, as it found 9670 old ones.
    FileCount=$(find "$CacheDir"
  • Answering No to the delete confirmation worked to abort.
  • Answering Yes to the delete confirmation deleted everything but the .ppm files as expected.
  • Tested on a Mac Studio w/ Monterey (12.7.3) - a major version behind the current Ventura.
  • Tested against an older PMS that was run last in December 2023.
  • So it worked for me.

Asides -

  • I’ll do a fresh install of PMS to see if there’s any different behavior.
  • There’s also a bunch of useless PID code left in the host config portion for Apple Mac, sorry.
  • A solvable feature, also, is macOS supports that PMS start and stop, which we humorously included in the dbrepair readme.md but I couldn’t get the quoting to work for the osascript command when I put it within dbrepair.sh and spent like a week relearning shell and trying everything I could think of, only to find at some point, hours earlier, one of my qutoting script attempts had nuked my PATH and that’s why I was getting errors. But by then I had tried everything and the kitchen sink, none of which worked, so unlearned everything and was left in a funk while you all solved a bunch of transcoder fun. lol.
2 Likes

Thank you.

Should I delete the PPM files ?

looks like they came from my music collection, most are 17 KB or 30 KB.
i had 386 from a small music collection.
deleting them would be in the spirit of the function.
many were from 2022 so they aren’t pruned like the rest by PMS automatically.

v1.05.01 is now available for upgrade .

Thanks for the help

1 Like

@gre483

What you want is not possbie.