Gotcha. I didn’t know about the ignore for constraint errors. I’ll definitely be using your tool regularly to check on my DB from now on though
From the README.md
The menu
The menu gives you the option to enter either a 'command number' or the 'command name/abbreviation'. For clarity, each command's name is 'quoted'.
Plex Media Server Database Repair Utility (_host_configuration_name_)
Version v1.03.00
Select
1 - 'stop' - Stop PMS.
2 - 'automatic' - Check, Repair/Optimize, and Reindex Database in one step.
3 - 'check' - Perform integrity check of database.
4 - 'vacuum' - Remove empty space from database without optimizing.
5 - 'repair' - Repair/Optimize databases.
6 - 'reindex' - Rebuild database database indexes.
7 - 'start' - Start PMS
8 - 'import' - Import watch history from another database independent of Plex. (risky).
9 - 'replace' - Replace current databases with newest usable backup copy (interactive).
10 - 'show' - Show logfile.
11 - 'status' - Report status of PMS (run-state and databases).
12 - 'undo' - Undo last successful command.
21 - 'prune' - Prune (remove) old image files (jpeg,jpg,png) from PhotoTranscoder cache.
42 - 'ignore' - Ignore duplicate/constraint errors.
88 - 'update' - Check for updates.
99 - 'quit' - Quit immediately. Keep all temporary files.
'exit' - Exit with cleanup options.
Enter command # -or- command name (4 char min) :
Menu command “ignore/honor” (number 42)
ALL:
There is a known issue where DBRepair cannot be run in certain container environments due to how HealthCheck works.
For those impacted platforms, an enhancement was requested after the tech support team realized the core issue.
While waiting for that --AND-- while resolving a new issue with PMS 1.40.x and above on all platforms,
I have an update: v1.06.00
This has been requested several times but I’ve not been too keen on doing it.
Today, a few critical
cleared and I saw how to implement.
Here are the details:
- “EXIT” is no longer required when all options are on the command line:
e.gDBRepair.sh stop auto start exit
– becomes –
DBrepair.sh stop auto start
Just as it should be
THIS IS Proof of Concept and subject to removal if not viable for all.
- You may now run DBepair.sh OUTSIDE containers in “Manual Mode”
–PROVIDED–
- You can specify the directory containing “Plex SQLite”
- You can specify the directory containing the databases
- You run as ‘root’ or (minimally) the UID owning those files.
- Your ‘stat’ command accepts
-coption - (MOST IMPORTANT) your /bin/sh /bin/bash is NOT a “Busybox” minimalist.
Below , please find the tar ball containing v1.06.00 ALPHA , Release Notes, and Readme.
Example Syntax: (with other options for example sake)
./DBRepair.sh \
-i -p \
--sqlite "/path/to/plexmediaserver/code/dir" \
--databases "/sata/dockerplex/config/Library/Application Support/Plex Media Server/Plug-in Support/Databases" \
stop auto start
Supplemental question
I am contemplating making the executable code with text menu (curses style).
If done, it will be either “AppImage” or stand alone for x86 platforms.
(Not equipped to do ARMv8 or ARMv7 development)
Bug fixed ![]()
DBRepair-v1.06.0-01-May-2024.tar (140 KB)
Please let me know how it behaves and if still in working orderr ![]()
I think I can add it to the preprogrammed sequence --IF-- the ‘forfiles’ command worked as it’s documented ![]()
This is not “PowerShell” and I’m not a Windows developer
Thanks!
Version 1.06.00 has been released.
It includes an update for Windows systems.
This first update provides support for 32 bit PMS on 64 bit Windows
(a ‘weird’ installation configuration)
Hopefully there will be progress on automatic pruning for Windows too
The tool is purely awesome! Thanks ChuckPa!
Just checked the “prune” function and it found 948496 files - just deleted them - wow, it freed over a hundred gigs…
Before => /dev/nvme1n1p1 492G 160G 327G 33% /mnt/appdata1
After => /dev/nvme1n1p1 492G 42G 445G 9% /mnt/appdata1
Hey @ChuckPa was wondering if there’s a workaround to repair a shield install, like moving it to the same location for say a windows installation and running it there? Similar to what we do with the inbuilt repair function for Plex.
No. There is nothing for Android native due to how it all works.
HOWEVER ---- ![]()
If you were to:
- Have PMS installed on a Linux computer
- Temporarily plug the Shield’s external HDD (the one you use for Plex) into the computer.
- You can use the Manual option to get --sqlite and --databases (as root)
- With that, it’ll operate on the DB files just as if a native PMS
(put that in a shell script or alias for easy access in the future and you’re all set)
Got it. Thanks
@ChuckPa ok here’s a weird question but it’s due to trying to make this work with multiple plex docker containers on 1 server that I thought of this.
If I take a database copy from Linux server A can I run this script on it on my Win-11 PC then upload it back in, chown chmod, etc and it should work? Or is there anything that might need to be run afterward due to database changes?
Please don’t mix Windows databases and Linux databases. They are not compatible.
If you have multiple docker containers on Linux then you should now consider using the capability I released as of 1.06.02 (running DBRepair outside of containers when the image is shutdown)
I don’t know why you’re running multiple docker containers… Are you a pirate ? ![]()
Jack Sparrow on a good Day maybe… ![]()
![]()
![]()
![]()
I think I may have made my database problems worse by using the repair script - now most Plex functions no longer work and the repair script can’t even stop PMS to try further repairs. Am I screwed? Help recovering a malformed database
I need more info than that please.
- Go into the Plex “Databases” directory.
- You’ll see
DBRepair.log - Attach that file here please.
- If you can make a ZIP file of the Plex “Logs” directory, please also attach it here.
I also need to know which version of PMS you’re using
-AND-
- Did you just upgrade to that version ?
- Did you, at any point, force restart / shutdown of your PMS ?
1)I don’t appreciate the insult. Are you a porcupine?
2) nobody said anything about mixing and matching, I asked if I could run the script on windows. server A db copies to home PC ,home PC runs script only, db now goes to server b and c .
You verified this is now possible thank you.
Now lets get back to the " Are you a Pirate " do we really want to go through the whole hassle of checking that EVERYONE on here is the owner of 100% of all media or software on their pc’s? Hell lets just start with the Plex home offices.
I dare ya to just do a quick survey of the 5 people next to you ask them come on do it " can you say 100% truthful not trump truth either that 100% of all software on every device you own is owned. "
So yeah Chuck are ya?
CHILL OUT PLEASE ?
It was meant as a joke, in a forum where we all know there are those who don’t own every single bit of content on their server…
That’s the whole point of the “wink, wink, – nudge, nudge”
My comment was over two weeks ago.
You’re just now coming and complaining.
I will be candid with you.
- I wrote the utility and support it to help people because I enjoy doing so.
- You’re taking fun out of it.
- Your sensitivity is coming across as guilt & defensive at getting caught.
- Please walk away