Thank you for your help. I have placed the DBRepair.sh file in the Plex Media Server Folder and have created the designated username and set the tasks up in Tasks Scheduler. I do not know how to make the .sh file executable as I have no experience with writing scripts. I’ve “Enabled SSH service” on my NAS but how do I know the repair is running? I believe I followed the steps correctly with the PleXDBRepair
@ChuckPa can you provide a walk thru? I dont have a syno so I am not familiar with that process
Trying to use CMD prompts (not experienced with this) and when I place the usernam@IP address, it asks for the password but then CMD won’t let me type anything. If I hit “Enter” it says access denied. So issues connecting via CMD.
I then tried to create a task thru Task Scheduler to start PlexDBRepair that I did get email with the command line options but since it’s in email, I cannot choose an option
I then went back to the Task I created to the task I changed the CMD lines to:
"#!/bin/bash
Go to the PlexMediaServer shared folder
cd /volume1/PlexMediaServer
sudo bash
tar xf PlexDBRepair-1.07.00.tar.gz
cd PlexDBRepair-1.07.00
chmod +x DBRepair.sh
./DBRepair.sh
Run classic Stop PMS, Automatic optimization/repair, Start PMS, and exit sequence
sudo ./DBRepair.sh stop auto start exit"
Since I was able to get the below command to run and send to my Email.
cd /volume1/PlexMediaServer
sudo bash
tar xf PlexDBRepair-1.07.00.tar.gz
cd PlexDBRepair-1.07.00
chmod +x DBRepair.sh
./DBRepair.sh
I believe it’s now running as I have not received an email saying it has ended in error yet and the status light is flashing on the NAS
Designated Username
What “designated username” did you create? It is not necessary to create a username to use DBRepair.
Scheduled Task
What you have running as a scheduled task will not work, since you did not give DBRepair any options (stop/auto/etc.).
Run from command line
Ideally, you should initially run DBRepair from the command line, not as a scheduled task. Doing so will let you replace the database with a backup version if necessary.
Copy / Paste in a SSH window
When using SSH, do not use Ctrl+C for copy or Ctrl+V for paste. In a Linux window, Ctrl+C will cancel the command. To paste into a Linux window, use a right mouse click.
To copy from Windows & paste into SSH:
To copy/paste one of the commands below into the SSH window, select it with your mouse, then right click and choose copy. Then, change to the SSH window and click the right mouse button. It will paste the text into the window.
To copy from SSH and paste into Windows:
To copy the text in a SSH window, select it with your mouse. Left click & hold at the start of the text you wish to select. Then drag to the bottom of the text. The selected text will be highlighted. To paste, switch to the desired Windows window (text file, browser window, etc.), right mouse click, and choose paste as plain text (or just paste).
Downloading & running DBRepair
Here’s the commands to ssh to the NAS and download & run DBrepair:
# ssh to the NAS, username = your DSM login; IP = the IP address of the NAS
# On Windows run from the c:\ prompt, either CMD or PowerShell.
# On Mac/Linux, run from a terminal sessions.
c:\ssh username@IP
# cd to Plex Data Directory (DSM 7)
cd /var/packages/PlexMediaServer/shares/PlexMediaServer
# Download latest version.
# This overwrites any existing version. Remove "-O DBRepair.sh" to not overwrite.
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. You will be asked for the NAS admin password
sudo ./DBRepair.sh
Once DBRepair is running
stop - Plex must be stopped for DBRepair to work
auto - this combines check, repair, & reindex into one step
If auto successfully repairs the database, then start and exit.
If auto cannot repair the database, choose replace. This will lead you through using a backup of the database (the db files with dates appended). It will check to see if they are OK. If any are OK, it will replace the damaged db with the backup. Then you can start and exit.
Example: SSH to Synology NAS, login, and launch DBRepair
c:\>ssh l0newo1f@192.168.1.49
The authenticity of host '192.168.1.49 (192.168.1.49)' can't be established.
ECDSA key fingerprint is <deleted>.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '192.168.1.49' (ECDSA) to the list of known hosts.
l0newo1f@192.168.1.49's password:
Synology strongly advises you not to run commands as the root user, who has
the highest privileges on the system. Doing so may cause major damages
to the system. Please note that if you choose to proceed, all consequences are
at your own risk.
L0neWo1f@tonkawa:~$ cd /var/packages/PlexMediaServer/shares/PlexMediaServer
L0neWo1f@tonkawa:/var/packages/PlexMediaServer/shares/PlexMediaServer$ wget -O DBRepair.sh https://github.com/ChuckPa/PlexDBRepair/releases/latest/download/DBRepair.sh
--2024-09-28 10:19:07-- https://github.com/ChuckPa/PlexDBRepair/releases/latest/download/DBRepair.sh
< Download lines deleted>
2024-09-28 10:19:09 (6.36 MB/s) - 'DBRepair.sh' saved [67768/67768]
L0neWo1f@tonkawa:/var/packages/PlexMediaServer/shares/PlexMediaServer$ chmod a+x DBRepair.sh
L0neWo1f@tonkawa:/var/packages/PlexMediaServer/shares/PlexMediaServer$ sudo ./DBRepair.sh
Password:
Plex Media Server Database Repair Utility (Synology (DSM 7))
Version v1.07.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) :
Thank you @FordGuy61. I appreciate your help and I will keep this going forward.
Thank you @ChuckPa & @dbirch for taking time to help a NOOB like myself. I was able to get it to run as I described and database was corrected and it shows it was repaired.
I just logged onto PLex via Windows Interface and my server is now working! Man o man I really appreciate you. Wish I could repay you in some way but thank you for helping me to recover this.
Glad you’re up and running.
Suggestion: Run DBRepair about once a month to keep the database optimized. It will make Plex more responsive, especially if you have added or removed a lot of media.
If you do not need interactive mode to try and replace a database, you can run it from one line: sudo ./DBRepair.sh stop auto start exit
Thank you once again
So, I got a similar problem, Plex runs and stop after 1 minute, tried DBrepair.sh, in both automatic and replacing to a older DB, but no prevail.
Log says;
Plex Media Server log entries
Oct 06, 2024 13:19:55.690 [140414526061368] INFO - Plex Media Server v1.41.0.8911-1bd569c5f - Synology DS718+ x86_64 - build: linux-x86_64 synology-dsm72 - GMT 02:00
Oct 06, 2024 13:19:55.691 [140414526061368] INFO - Linux version: DSM 7.2.2.72806-0, language: en-US
Oct 06, 2024 13:19:55.691 [140414526061368] INFO - Processor: 4-core Intel(R) Celeron(R) CPU J3455 @ 1.50GHz
Oct 06, 2024 13:19:55.691 [140414526061368] INFO - Compiler is - Clang 11.0.1 (https://plex.tv 9b997da8e5b47bdb4a9425b3a3b290be393b4b1f)
Oct 06, 2024 13:19:55.691 [140414526061368] INFO - /volume2/@appstore/PlexMediaServer/Plex Media Server
Oct 06, 2024 13:19:55.689 [140414528604816] DEBUG - BPQ: [Idle] -> [Starting]
Oct 06, 2024 13:19:55.712 [140414528604816] DEBUG - FeatureManager: Using cached data for features list
Oct 06, 2024 13:19:55.718 [140414528604816] DEBUG - MyPlex: mapping state set to 'Unknown'.
Oct 06, 2024 13:19:55.720 [140414528604816] DEBUG - Relay: read 140 cached entries from hosts file
Oct 06, 2024 13:19:55.721 [140414528604816] DEBUG - Opening 20 database sessions to library (com.plexapp.plugins.library), SQLite 3.39.4, threadsafe=1
Oct 06, 2024 13:19:55.814 [140414528604816] DEBUG - MyPlex: no cached data to load for request for https://plex.tv/api/v2/server/users/features
Oct 06, 2024 13:19:55.866 [140414528604816] DEBUG - [CERT] Subject name is /CN=*.47dcfa9e40ce4b9bace2d30f74448c5a.plex.direct
Oct 06, 2024 13:19:55.866 [140414528604816] DEBUG - [CERT] Installed certificate with fingerprint b8:8a:06:08:51:69:72:e4:8b:7c:a0:56:70:d6:9f:0c:d7:30:dd:fe.
Oct 06, 2024 13:19:55.866 [140414528604816] DEBUG - [CERT/OCSP] Stapling requests will be made to 'http://r10.o.lencr.org/'.
Oct 06, 2024 13:19:55.866 [140414528604816] INFO - [CERT/OCSP] Successfully retrieved response from cache.
Oct 06, 2024 13:19:55.867 [140414528604816] DEBUG - HttpServer: Listening on port 32400.
Oct 06, 2024 13:19:55.867 [140414528604816] DEBUG - HttpServer: Listening on port 32401.
Oct 06, 2024 13:19:55.867 [140414528604816] DEBUG - Running server...
Oct 06, 2024 13:19:55.868 [140414528604816] INFO - Running migrations. (EPG 0)
Oct 06, 2024 13:19:55.868 [140414508108600] DEBUG - HttpServer: Set up a thread pool with 2 threads.
Oct 06, 2024 13:19:55.869 [140414528604816] DEBUG - Captured session 0.
Oct 06, 2024 13:19:55.869 [140414528604816] DEBUG - Captured session 1.
Oct 06, 2024 13:19:55.869 [140414528604816] DEBUG - Captured session 2.
Oct 06, 2024 13:19:55.869 [140414528604816] DEBUG - Captured session 3.
Oct 06, 2024 13:19:55.869 [140414528604816] DEBUG - Captured session 4.
Oct 06, 2024 13:19:55.869 [140414528604816] DEBUG - Captured session 5.
Oct 06, 2024 13:19:55.869 [140414528604816] DEBUG - Captured session 6.
Oct 06, 2024 13:19:55.869 [140414528604816] DEBUG - Captured session 7.
Oct 06, 2024 13:19:55.869 [140414528604816] DEBUG - Captured session 8.
Oct 06, 2024 13:19:55.869 [140414528604816] DEBUG - Captured session 9.
Oct 06, 2024 13:19:55.869 [140414528604816] DEBUG - Captured session 10.
Oct 06, 2024 13:19:55.869 [140414528604816] DEBUG - Captured session 11.
Oct 06, 2024 13:19:55.869 [140414528604816] DEBUG - Captured session 12.
Oct 06, 2024 13:19:55.870 [140414528604816] DEBUG - Captured session 13.
Oct 06, 2024 13:19:55.870 [140414528604816] DEBUG - Captured session 14.
Oct 06, 2024 13:19:55.870 [140414528604816] DEBUG - Captured session 15.
Oct 06, 2024 13:19:55.870 [140414528604816] DEBUG - Captured session 16.
Oct 06, 2024 13:19:55.870 [140414528604816] DEBUG - Captured session 17.
Oct 06, 2024 13:19:55.870 [140414528604816] DEBUG - Captured session 18.
Oct 06, 2024 13:19:55.870 [140414528604816] DEBUG - Captured session 19.
Oct 06, 2024 13:19:55.875 [140414528604816] INFO - Running forward migration 202309200901.
Oct 06, 2024 13:19:55.875 [140414528604816] DEBUG - Captured session 0.
Oct 06, 2024 13:19:55.875 [140414528604816] DEBUG - Captured session 1.
Oct 06, 2024 13:19:55.875 [140414528604816] DEBUG - Captured session 2.
Oct 06, 2024 13:19:55.875 [140414528604816] DEBUG - Captured session 3.
Oct 06, 2024 13:19:55.875 [140414528604816] DEBUG - Captured session 4.
Oct 06, 2024 13:19:55.875 [140414528604816] DEBUG - Captured session 5.
Oct 06, 2024 13:19:55.875 [140414528604816] DEBUG - Captured session 6.
Oct 06, 2024 13:19:55.875 [140414528604816] DEBUG - Captured session 7.
Oct 06, 2024 13:19:55.875 [140414528604816] DEBUG - Captured session 8.
Oct 06, 2024 13:19:55.875 [140414528604816] DEBUG - Captured session 9.
Oct 06, 2024 13:19:55.875 [140414528604816] DEBUG - Captured session 10.
Oct 06, 2024 13:19:55.875 [140414528604816] DEBUG - Captured session 11.
Oct 06, 2024 13:19:55.875 [140414528604816] DEBUG - Captured session 12.
Oct 06, 2024 13:19:55.875 [140414528604816] DEBUG - Captured session 13.
Oct 06, 2024 13:19:55.875 [140414528604816] DEBUG - Captured session 14.
Oct 06, 2024 13:19:55.875 [140414528604816] DEBUG - Captured session 15.
Oct 06, 2024 13:19:55.875 [140414528604816] DEBUG - Captured session 16.
Oct 06, 2024 13:19:55.876 [140414528604816] DEBUG - Captured session 17.
Oct 06, 2024 13:19:55.876 [140414528604816] DEBUG - Captured session 18.
Oct 06, 2024 13:19:55.876 [140414528604816] DEBUG - Captured session 19.
Oct 06, 2024 13:19:56.127 [140414528604816] ERROR - Exception inside transaction (inside=1) (/home/runner/actions-runner/_work/plex-media-server/plex-media-server/Library/DatabaseMigrations.cpp:342): Null value not allowed for this type
Oct 06, 2024 13:19:56.131 [140414528604816] ERROR - Exception thrown during migrations, aborting: Null value not allowed for this type
Oct 06, 2024 13:19:56.131 [140414528604816] ERROR - Database corruption: Null value not allowed for this type
Oct 06, 2024 13:19:56.131 [140414528604816] ERROR - Error: Unable to set up server: Null value not allowed for this type (N4soci10soci_errorE)
Oct 06, 2024 13:19:56.131 [140414528604816] DEBUG - [JobRunner] Job running: /volume2/@appstore/PlexMediaServer/CrashUploader --sessionStatus=abnormal --sessionStart=1728213595 --sessionDuration=1 --version=1.41.0.8911-1bd569c5f --userId=XXX@XXX.se --sentryUrl=https://o17675.ingest.sentry.io/api/1233455/ --sentryKey=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Oct 06, 2024 13:19:56.131 [140414528604816] DEBUG - [JobRunner] Jobs: Starting child process with pid 4594
Mod Edit: Formatting. @FordGuy61
With Plex Media Server stopped, open the database in Plex SQLite and issue the DELETE from external_metadata_items; command.
- Plex Media Server must be stopped.
- Must run as root (sudo).
- Don’t miss the semicolon at the end of the command.
On my Synology running DSM 7. You should be able to copy/paste the lines.
L0neWo1f@tonkawa:~$ sudo "/var/packages/PlexMediaServer/target/Plex SQLite" "/var/packages/PlexMediaServer/shares/PlexMediaServer/AppData/Plex Media Server/Plug-in Support/Databases/com.plexapp.plugins.library.db"
SQLite version 3.39.4 2022-09-29 15:55:41
Enter ".help" for usage hints.
sqlite> DELETE from external_metadata_items;
sqlite> .quit
L0neWo1f@tonkawa:~$
When finished, run DBRepair.
sudo ./DBRepair.sh stop auto start exit
Then see if Plex Media Server runs OK.
References:
This thread mentions the Null value not allowed... error message and using DELETE.... to try and fix it: Upgrade to 1.40.0.7998 causes error - #28 by ChuckPa
Repair a Corrupt Database provides the location of Plex SQLite.
That worked, thank you so much, I’ve been googling and searching for hours!!!
uit
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.