UnluckyTECH

Repair Plex Database



There are several ways to repair a Plex database. In this post, we’ll cover two specific approaches: using the PlexDBRepair script by ChuckPa and manually repairing it with the Plex SQLite Tool.

PlexDBRepair

ChuckPa provides scripts that work on both Windows and Linux but they essentially work the same. If using docker then ensure you move the script within your plex container and execute it from there. Will specify more on the linux section.

You can download all the necessary scripts from this link. Unzip the file.

Windows

  1. Start
  2. Search CMD
  3. Right click on CMD
  4. Run as administrator

Navigate to the directory where the scripts reside in for windows…

cd \Users\unluckytech\Downloads\PlexDBRepair\Windows

The script we are using is a “bat” file but once here run the command below to start the recovery process…

DBRepair-Windows.bat

Linux

Launch your preferred terminal and change into the directory with the scripts…

cd /home/unluckytech/Downloads/PlexDBRepair

We will run the bash script so ensure it is executable…

sudo chmod +x ./DBRepair.sh

Then launch the script…

./DBRepair.sh

Docker

For docker you simply need to move the bash script into your plex container. This can be where your movies or shows are located or somewhere similar so we can use the script from the container.

mv PlexDBRepair.sh /home/docker/plex/movies

Then launch into your plex container to launch the script…

docker exec -it <container_name> /bin/bash

Navigate to the script…

cd /movies

From here you make the script executable and run from within the container. Refer to the linux section to make the script executable.

PlexDBRepair Menu

Once you run the script you will see this menu…

      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 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) :
  1. Stop plex if you havent done so already or select “1”
  2. Select “2” to begin the automatic repair

It will begin creating a backup of your current database and then start the process in repairing your database. For me it took 10-15 minutes to repair.

Once completed you can then type “exit” to leave the script and relaunch plex.

Manually Repair Database

Refer here for official docs