GUI based database corruption identification/repair

Given the way Plex Media Server is currently built, performing a database repair within the Plex UI is not possible. To repair the database, Plex Media Server must be stopped, so the database is closed. If Plex Media Server is stopped, then the Plex UI is not available.

You can repair the database without having to issue SQLite commands.

Please see @ChuckPa’s Plex DB Repair tool.

The Readme has instructions for multiple platforms, Docker, etc.

Using the tool is straightforward.

Download it (entire command on one line)

wget -O DBRepair.sh https://github.com/ChuckPa/PlexDBRepair/releases/latest/download/DBRepair.sh

Make it executable: chmod a+x DBRepair.sh

Run it (as root): sudo ./DBRepair.sh

  • Use Stop, then Auto.
  • If it can fix the db (or it is OK), then Start and Exit.
  • If the db cannot be repaired, try Replace.

Example: This is on my Synology NAS. It will look the same on Ubuntu, etc.

PlexDBRepair Download and Run
$ wget -O DBRepair.sh https://github.com/ChuckPa/PlexDBRepair/releases/latest/download/DBRepair.sh

<< a lot of lines deleted >>

Saving to: 'DBRepair.sh'
DBRepair.sh     100%[==========================================================>]  68.37K  --.-KB/s    in 0.002s
2025-05-04 22:30:07 (30.2 MB/s) - 'DBRepair.sh' saved [70012/70012]

$ chmod a+x DBRepair.sh

$ sudo ./DBRepair.sh


      Plex Media Server Database Repair Utility (Synology (DSM 7))
                       Version v1.10.03


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 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'     - Remove old image files (jpeg,jpg,png) from PhotoTranscoder cache & all temp files left by PMS.
 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) :

Example output of Auto:

PlexDBRepair Auto
Automatic Check,Repair,Index started.

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

Exporting current databases using timestamp: 2025-05-04_22.34.17
Exporting Main DB
Exporting Blobs DB
Successfully exported the main and blobs databases.
Start importing into new databases.
Importing Main DB.
Importing Blobs DB.
Successfully imported databases.
Verifying databases integrity after importing.
Verification complete.  PMS main database is OK.
Verification complete.  PMS blobs database is OK.
Saving current databases with '-BACKUP-2025-05-04_22.34.17'
Making repaired databases active
Repair complete. Please check your library settings and contents for completeness.
Recommend:  Scan Files and Refresh all metadata for each library section.

Backing up of databases
Backup current databases with '-BACKUP-2025-05-04_22.38.23' timestamp.
Reindexing main database
Reindexing main database successful.
Reindexing blobs database
Reindexing blobs database successful.
Reindex complete.
Automatic Check, Repair/optimize, & Index successful.