DBRepair development

ALL:

After a lot of work, and testing, and rework, and even more testing :rofl:

I now have a new build for you all to try.
You’ll find it does a lot better and more than before:

As always, this is still under development so keeping a backup of your PMS databases is strongly recommended.

As the development becomes more stable, I will increase the “drop dead” timer in the code. This will afford the opportunity to find any lingering deep edge cases prior to full release.

Release Notes: (in the package as well)

v0.1999.06

  * All Platforms   - Corrected naming collision when saving state between commands.
                      This caused temp file overwrite on MacOS and Linux.
                      This also prevented the repaired file from being moved into position on Windows.
                      Corrections to databases would be lost just as it was about to be made active.

                    - Fixed database state(status) flags not properly managed between commands.
                      It would report damaged when it wasn't.

  * CheckDB         - Fixed error where DB would be reported as OK when it wasn't.
                      Fixed error where FTS would be reported as OK when it wasn't.
                      Flipped states and confusing reporting now fixed. 

  * FTS             - FTS tables now built per PMS requirements.   PMS 1.43.3 works.
                    - When rebuilding FTS tables, reports if orphaned items found.
                      These can be corrected by using PMS (Scan File + Refresh Metadata).
                    - Fixed case where FTS did not output what PMS requires. 

  * Schema          - Database schema creation now done per sqlite3 standard and Plex standards.
                      DBRepair.sh "Bulk Reload" technique no longer used.

  * Integrity Check - Database and FTS integrity checks are more accurate.   
                      False-positive FTS ("inverted index") error no longer occurs unless real. 
                    - The FTS check now actually runs SQLite's real integrity-check diagnostic
                      (previous versions ran a query that never invoked it. Damaged FTS could go
                      undetected).
                    - A functional check (a real search against real data) now backs up the
                      structural check,  since structure alone can't confirm Plex's index
                      is actually working.

  * History         - History no longer loses track of your last completed action (Repair,  Reindex,
                      Replace,  Revert). "Last Run" now correctly reflects it.
                    - Fixed a bug where Revert could fail to recognize an empty history under certain
                      conditions.

  * Linux           - /etc/systemd/system/plexmediaserver.service.d/override.conf did not parse
                      correctly.   Fixed.

  * Reliability     - Database connections are now always closed with error-trapping,  so a failed
                      close is reported instead of silently assumed successful.  Cleaned up code
                      internally. 

  * Option flags    - DBRepair now supports a limited number of command line options.
                      Unrecognized options are silently ignored.

                      Working DB Cache size:      -c or --cache Value_in_MB
                      Manual configuration:       --databases "/Directory/Containing/Databases"
                      Force bypass of DB checks:  -f or --force
                      Help:                       -h or --help
                      Ignore Import erroras:      -i or --ignore
                      Verbose output:             -v

                      **Note:   When FORCE is active, this will show in both console output and in DBRepair.log
                                for each instance it's active. Future version will have interactive control.
          
Known limitation:

  * Process Control - Windows hosts must "Run as Administrator" to correctly stop/start the Plex services
                      running in the background. This is per Windows requirements.

                      Windows hosts now require "Run as Administrator" privilege to run DBRepair.
                      (enforcement of the above "Run as Administrator" requirement).
  
                      PMS on Windows does not respond to termination signals as MacOS & Linux do. 
                      Plex has taken this as an action item to repair.

                      'root' privilege required on Linux hosts to start/stop plex. 

  * Permissions     - MacOS hosts run as the default username.  No special permissions required.
                      Linux hosts require 'root' permission to set ownership and permissions.

  * Signals         - Interrupting DBRepair (Control-C) is not yet handled (No cleanup). 
                      Will be supported in upcoming release. 

For your consideration:

What to expect:

chuck@tirol ~ % dbrepair/build/pc-darwin-arm64-release/bin/DBRepair 



            Database Repair Utility for Plex Media Server  (macOS 26.6.2 (Tahoe))
                       Version 0.1999.06 (Aug 21 2026)


Select

  1 - 'stop'      - Stop PMS.
  3 - 'check'     - Perform integrity check of database and FTS indexes.
  4 - 'vacuum'    - Remove empty space from database without optimizing.
  5 - 'repair'    - Repair/Optimize databases.
  6 - 'reindex'   - Rebuild database indexes.
  7 - 'start'     - Start PMS

 10 - 'show'      - Show logfile.
 11 - 'status'    - Report status of PMS (run-state and databases).
 12 - 'history'   - Show command history of this session.
 13 - 'revert'    - Revert DBs to immediately before history index.

 21 - 'prune'     - Remove old image files from PhotoTranscoder cache & all temp files left by PMS.
 23 - 'deflate'   - Deflate a bloated PMS main database.
 42 - 'ignore'    - Ignore duplicate/constraint errors.

 98 - 'quit'      - Quit immediately.  Keep all temporary files.
 99 - 'exit'      - Exit with cleanup options.

Enter command # -or- command name (4 char min) : ^C
chuck@tirol ~ %

As always, Your comments, feedback, bug reports, etc, are always welcomed.