Compare commits

..

5 Commits

Author SHA1 Message Date
Chuck
ec9edaf304 Merge pull request #152 from ChuckPa/chuckpa/plexsqlite-dir-path
v1.06.02
2024-05-11 03:43:05 -04:00
Chuck
2e92ba88de Update README.md 2024-05-11 03:30:10 -04:00
Chuck
57055172e0 Update README.md 2024-05-11 03:29:42 -04:00
ChuckPa
029020ebc5 v1.06.02 bug fix
Manual configuration mode error handling and reporting.
2024-05-11 02:37:37 -04:00
ChuckPa
32c30e6826 v1.06.01 - Support directory or full path with '--sqlite' option. 2024-05-10 18:04:12 -04:00
3 changed files with 59 additions and 41 deletions

View File

@@ -2,12 +2,12 @@
######################################################################### #########################################################################
# Plex Media Server database check and repair utility script. # # Plex Media Server database check and repair utility script. #
# Maintainer: ChuckPa # # Maintainer: ChuckPa #
# Version: v1.06.00 # # Version: v1.06.02 #
# Date: 01-May-2024 # # Date: 11-May-2024 #
######################################################################### #########################################################################
# Version for display purposes # Version for display purposes
Version="v1.06.00" Version="v1.06.02"
# Have the databases passed integrity checks # Have the databases passed integrity checks
CheckedDB=0 CheckedDB=0
@@ -46,6 +46,8 @@ HostType=""
LOG_TOOL="echo" LOG_TOOL="echo"
ShowMenu=1 ShowMenu=1
Exit=0 Exit=0
Scripted=0
HaveStartStop=0
# On all hosts except Mac # On all hosts except Mac
PIDOF="pidof" PIDOF="pidof"
@@ -373,8 +375,8 @@ HostConfig() {
# Manual Config # Manual Config
if [ $ManualConfig -eq 1 ]; then if [ $ManualConfig -eq 1 ]; then
CacheDir="$DBDIR/../../Cache" CACHEDIR="$DBDIR/../../Cache/PhotoTranscoder"
Logfile="$DBDIR/DBRepair.log" LOGFILE="$DBDIR/DBRepair.log"
HostType="MANUAL" HostType="MANUAL"
return 0 return 0
fi fi
@@ -391,7 +393,7 @@ HostConfig() {
# Where is the data # Where is the data
AppSuppDir="/var/packages/PlexMediaServer/shares/PlexMediaServer/AppData" AppSuppDir="/var/packages/PlexMediaServer/shares/PlexMediaServer/AppData"
DBDIR="$AppSuppDir/Plex Media Server/Plug-in Support/Databases" DBDIR="$AppSuppDir/Plex Media Server/Plug-in Support/Databases"
CacheDir="$AppSuppDir/Plex Media Server/Cache/PhotoTranscoder" CACHEDIR="$AppSuppDir/Plex Media Server/Cache/PhotoTranscoder"
PID_FILE="$AppSuppDir/Plex Media Server/plexmediaserver.pid" PID_FILE="$AppSuppDir/Plex Media Server/plexmediaserver.pid"
LOGFILE="$DBDIR/DBRepair.log" LOGFILE="$DBDIR/DBRepair.log"
@@ -421,7 +423,7 @@ HostConfig() {
if [ -d "$AppSuppDir/Plex Media Server" ]; then if [ -d "$AppSuppDir/Plex Media Server" ]; then
DBDIR="$AppSuppDir/Plex Media Server/Plug-in Support/Databases" DBDIR="$AppSuppDir/Plex Media Server/Plug-in Support/Databases"
CacheDir="$AppSuppDir/Plex Media Server/Cache/PhotoTranscoder" CACHEDIR="$AppSuppDir/Plex Media Server/Cache/PhotoTranscoder"
PID_FILE="$AppSuppDir/Plex Media Server/plexmediaserver.pid" PID_FILE="$AppSuppDir/Plex Media Server/plexmediaserver.pid"
LOGFILE="$DBDIR/DBRepair.log" LOGFILE="$DBDIR/DBRepair.log"
@@ -446,7 +448,7 @@ HostConfig() {
# Where is the data # Where is the data
AppSuppDir="$PKGDIR/Library" AppSuppDir="$PKGDIR/Library"
DBDIR="$AppSuppDir/Plex Media Server/Plug-in Support/Databases" DBDIR="$AppSuppDir/Plex Media Server/Plug-in Support/Databases"
CacheDir="$AppSuppDir/Plex Media Server/Cache/PhotoTranscoder" CACHEDIR="$AppSuppDir/Plex Media Server/Cache/PhotoTranscoder"
PID_FILE="$AppSuppDir/Plex Media Server/plexmediaserver.pid" PID_FILE="$AppSuppDir/Plex Media Server/plexmediaserver.pid"
LOGFILE="$DBDIR/DBRepair.log" LOGFILE="$DBDIR/DBRepair.log"
@@ -469,7 +471,7 @@ HostConfig() {
# Where things are # Where things are
PLEX_SQLITE="/snap/plexmediaserver/current/Plex SQLite" PLEX_SQLITE="/snap/plexmediaserver/current/Plex SQLite"
AppSuppDir="/var/snap/plexmediaserver/common/Library/Application Support" AppSuppDir="/var/snap/plexmediaserver/common/Library/Application Support"
CacheDir="$AppSuppDir/Plex Media Server/Cache/PhotoTranscoder" CACHEDIR="$AppSuppDir/Plex Media Server/Cache/PhotoTranscoder"
PID_FILE="$AppSuppDir/plexmediaserver.pid" PID_FILE="$AppSuppDir/plexmediaserver.pid"
DBDIR="$AppSuppDir/Plex Media Server/Plug-in Support/Databases" DBDIR="$AppSuppDir/Plex Media Server/Plug-in Support/Databases"
LOGFILE="$DBDIR/DBRepair.log" LOGFILE="$DBDIR/DBRepair.log"
@@ -511,7 +513,7 @@ HostConfig() {
fi fi
DBDIR="$AppSuppDir/Plex Media Server/Plug-in Support/Databases" DBDIR="$AppSuppDir/Plex Media Server/Plug-in Support/Databases"
CacheDir="$AppSuppDir/Plex Media Server/Cache/PhotoTranscoder" CACHEDIR="$AppSuppDir/Plex Media Server/Cache/PhotoTranscoder"
PID_FILE="$AppSuppDir/Plex Media Server/plexmediaserver.pid" PID_FILE="$AppSuppDir/Plex Media Server/plexmediaserver.pid"
LOGFILE="$DBDIR/DBRepair.log" LOGFILE="$DBDIR/DBRepair.log"
@@ -535,7 +537,7 @@ HostConfig() {
AppSuppDir="$PKGDIR/MediaLibrary" AppSuppDir="$PKGDIR/MediaLibrary"
PID_FILE="$AppSuppDir/Plex Media Server/plexmediaserver.pid" PID_FILE="$AppSuppDir/Plex Media Server/plexmediaserver.pid"
DBDIR="$AppSuppDir/Plex Media Server/Plug-in Support/Databases" DBDIR="$AppSuppDir/Plex Media Server/Plug-in Support/Databases"
CacheDir="$AppSuppDir/Plex Media Server/Cache/PhotoTranscoder" CACHEDIR="$AppSuppDir/Plex Media Server/Cache/PhotoTranscoder"
LOGFILE="$DBDIR/DBRepair.log" LOGFILE="$DBDIR/DBRepair.log"
LOG_TOOL="logger" LOG_TOOL="logger"
@@ -556,7 +558,7 @@ HostConfig() {
AppSuppDir="/volume1/Plex/Library" AppSuppDir="/volume1/Plex/Library"
PID_FILE="$AppSuppDir/Plex Media Server/plexmediaserver.pid" PID_FILE="$AppSuppDir/Plex Media Server/plexmediaserver.pid"
DBDIR="$AppSuppDir/Plex Media Server/Plug-in Support/Databases" DBDIR="$AppSuppDir/Plex Media Server/Plug-in Support/Databases"
CacheDir="$AppSuppDir/Plex Media Server/Cache/PhotoTranscoder" CACHEDIR="$AppSuppDir/Plex Media Server/Cache/PhotoTranscoder"
LOGFILE="$DBDIR/DBRepair.log" LOGFILE="$DBDIR/DBRepair.log"
LOG_TOOL="logger" LOG_TOOL="logger"
@@ -572,7 +574,7 @@ HostConfig() {
PLEX_SQLITE="/Applications/Plex Media Server.app/Contents/MacOS/Plex SQLite" PLEX_SQLITE="/Applications/Plex Media Server.app/Contents/MacOS/Plex SQLite"
AppSuppDir="$HOME/Library/Application Support" AppSuppDir="$HOME/Library/Application Support"
DBDIR="$AppSuppDir/Plex Media Server/Plug-in Support/Databases" DBDIR="$AppSuppDir/Plex Media Server/Plug-in Support/Databases"
CacheDir="$HOME/Library/Caches/PlexMediaServer/PhotoTranscoder" CACHEDIR="$HOME/Library/Caches/PlexMediaServer/PhotoTranscoder"
PID_FILE="$DBDIR/dbtmp/plexmediaserver.pid" PID_FILE="$DBDIR/dbtmp/plexmediaserver.pid"
LOGFILE="$DBDIR/DBRepair.log" LOGFILE="$DBDIR/DBRepair.log"
LOG_TOOL="logger" LOG_TOOL="logger"
@@ -608,7 +610,7 @@ HostConfig() {
AppSuppDir="$(echo /mnt/HD/HD*/Nas_Prog/plex_conf)" AppSuppDir="$(echo /mnt/HD/HD*/Nas_Prog/plex_conf)"
PID_FILE="$AppSuppDir/Plex Media Server/plexmediaserver.pid" PID_FILE="$AppSuppDir/Plex Media Server/plexmediaserver.pid"
DBDIR="$AppSuppDir/Plex Media Server/Plug-in Support/Databases" DBDIR="$AppSuppDir/Plex Media Server/Plug-in Support/Databases"
CacheDir="$AppSuppDir/Plex Media Server/Cache/PhotoTranscoder" CACHEDIR="$AppSuppDir/Plex Media Server/Cache/PhotoTranscoder"
LOGFILE="$DBDIR/DBRepair.log" LOGFILE="$DBDIR/DBRepair.log"
LOG_TOOL="logger" LOG_TOOL="logger"
@@ -628,7 +630,7 @@ HostConfig() {
AppSuppDir="/config" AppSuppDir="/config"
PID_FILE="$AppSuppDir/plexmediaserver.pid" PID_FILE="$AppSuppDir/plexmediaserver.pid"
DBDIR="$AppSuppDir/Plug-in Support/Databases" DBDIR="$AppSuppDir/Plug-in Support/Databases"
CacheDir="$AppSuppDir/Plex Media Server/Cache/PhotoTranscoder" CACHEDIR="$AppSuppDir/Plex Media Server/Cache/PhotoTranscoder"
LOGFILE="$DBDIR/DBRepair.log" LOGFILE="$DBDIR/DBRepair.log"
LOG_TOOL="logger" LOG_TOOL="logger"
if [ -d "/run/service/plex" ] || [ -d "/run/service/service-plex" ]; then if [ -d "/run/service/plex" ] || [ -d "/run/service/service-plex" ]; then
@@ -648,7 +650,7 @@ HostConfig() {
AppSuppDir="/config/Library/Application Support" AppSuppDir="/config/Library/Application Support"
PID_FILE="$AppSuppDir/Plex Media Server/plexmediaserver.pid" PID_FILE="$AppSuppDir/Plex Media Server/plexmediaserver.pid"
DBDIR="$AppSuppDir/Plex Media Server/Plug-in Support/Databases" DBDIR="$AppSuppDir/Plex Media Server/Plug-in Support/Databases"
CacheDir="$AppSuppDir/Plex Media Server/Cache/PhotoTranscoder" CACHEDIR="$AppSuppDir/Plex Media Server/Cache/PhotoTranscoder"
LOGFILE="$DBDIR/DBRepair.log" LOGFILE="$DBDIR/DBRepair.log"
LOG_TOOL="logger" LOG_TOOL="logger"
@@ -677,7 +679,7 @@ HostConfig() {
AppSuppDir="/config" AppSuppDir="/config"
PID_FILE="$AppSuppDir/Plex Media Server/plexmediaserver.pid" PID_FILE="$AppSuppDir/Plex Media Server/plexmediaserver.pid"
DBDIR="$AppSuppDir/Plex Media Server/Plug-in Support/Databases" DBDIR="$AppSuppDir/Plex Media Server/Plug-in Support/Databases"
CacheDir="$AppSuppDir/Plex Media Server/Cache/PhotoTranscoder" CACHEDIR="$AppSuppDir/Plex Media Server/Cache/PhotoTranscoder"
LOGFILE="$DBDIR/DBRepair.log" LOGFILE="$DBDIR/DBRepair.log"
LOG_TOOL="logger" LOG_TOOL="logger"
@@ -718,7 +720,7 @@ HostConfig() {
fi fi
DBDIR="$AppSuppDir/Plex Media Server/Plug-in Support/Databases" DBDIR="$AppSuppDir/Plex Media Server/Plug-in Support/Databases"
CacheDir="$AppSuppDir/Plex Media Server/Cache/PhotoTranscoder" CACHEDIR="$AppSuppDir/Plex Media Server/Cache/PhotoTranscoder"
LOGFILE="$DBDIR/DBRepair.log" LOGFILE="$DBDIR/DBRepair.log"
LOG_TOOL="logger" LOG_TOOL="logger"
HostType="$(grep PRETTY_NAME /etc/os-release | sed -e 's/^.*="//' | tr -d \" )" HostType="$(grep PRETTY_NAME /etc/os-release | sed -e 's/^.*="//' | tr -d \" )"
@@ -1619,7 +1621,7 @@ DoPrunePhotoTranscoder() {
PruneIt=1 PruneIt=1
else else
Output "Counting how many files are more than $CacheAge days old." Output "Counting how many files are more than $CacheAge days old."
FileCount=$(find "$CacheDir" \( -name \*.jpg -o -name \*.jpeg -o -name \*.png -o -name \*.ppm \) -mtime +${CacheAge} -print | wc -l) FileCount=$(find "$CACHEDIR" \( -name \*.jpg -o -name \*.jpeg -o -name \*.png -o -name \*.ppm \) -mtime +${CacheAge} -print | wc -l)
# If nothing found, continue back to the menu # If nothing found, continue back to the menu
[ $FileCount -eq 0 ] && Output "No files found to prune." && return [ $FileCount -eq 0 ] && Output "No files found to prune." && return
@@ -1634,7 +1636,7 @@ DoPrunePhotoTranscoder() {
if [ $PruneIt -eq 1 ]; then if [ $PruneIt -eq 1 ]; then
Output "Pruning started." Output "Pruning started."
WriteLog "Prune - Removing $FileCount files over $CacheAge days old." WriteLog "Prune - Removing $FileCount files over $CacheAge days old."
find "$CacheDir" \( -name \*.jpg -o -name \*.jpeg -o -name \*.png \) -mtime +${CacheAge} -delete find "$CACHEDIR" \( -name \*.jpg -o -name \*.jpeg -o -name \*.png \) -mtime +${CacheAge} -delete
Output "Pruning completed." Output "Pruning completed."
WriteLog "Prune - PASS." WriteLog "Prune - PASS."
fi fi
@@ -1661,15 +1663,21 @@ do
[ "$Opt" = "-f" ] && shift [ "$Opt" = "-f" ] && shift
[ "$Opt" = "-p" ] && shift [ "$Opt" = "-p" ] && shift
# Manual configuration options (running outside of container) # Manual configuration options (running outside of container or unusual hosts)
if [ "$Opt" = "--sqlite" ]; then if [ "$Opt" = "--sqlite" ]; then
# Manually specify path to where Plex SQLite is installed. # Is this the directory where Plex SQLite exists?
if [ -d "$2" ] && [ -f "$2/Plex SQLite" ]; then if [ -d "$2" ] && [ -f "$2/Plex SQLite" ]; then
PLEX_SQLITE="$2/Plex SQLite" PLEX_SQLITE="$2/Plex SQLite"
ManualConfig=1 ManualConfig=1
# Or is it the direct path to Plex SQLite
elif echo "$2" | grep "Plex SQLite" > /dev/null && [ -f "$2" ] ; then
PLEX_SQLITE="$2"
else else
Output "Given directory path ('$1') for Plex SQLite is invalid. Ignoring." Output "Given 'Plex SQLite' directory/path ('$2') is invalid. Aborting."
exit 2
fi fi
shift 2 shift 2
fi fi
@@ -1679,15 +1687,18 @@ do
# Manual path to databases # Manual path to databases
if [ "$Opt" = "--databases" ]; then if [ "$Opt" = "--databases" ]; then
# Manually specify path to where the databases reside # Manually specify path to where the databases reside and set all dependent dirs
if [ -d "$2" ] && [ -f "$2"/com.plexapp.plugins.library.db ]; then if [ -d "$2" ] && [ -f "$2"/com.plexapp.plugins.library.db ]; then
DBDIR="$2" DBDIR="$2"
ManualConfig=1 AppSuppDir="$(dirname "$(dirname "$(dirname "$DBDIR")")")"
CACHEDIR="$AppSuppDir/Plex Media Server/Cache/PhotoTranscoder"
LOGFILE="$DBDIR/DBRepair.log" LOGFILE="$DBDIR/DBRepair.log"
AppSuppDir="$( dirname "$(dirname "$(dirname "$db")))")")" ManualConfig=1
else else
Output "Given directory path ('$1') for Plex databases is invalid. Ignoring." Output "Given Plex databases directory ('$2') is invalid. Aborting."
exit 2
fi fi
shift 2 shift 2
fi fi
@@ -1721,6 +1732,7 @@ Scripted=0
if [ $ManualConfig -eq 0 ] && ! HostConfig; then if [ $ManualConfig -eq 0 ] && ! HostConfig; then
Output 'Error: Unknown host. Current supported hosts are: QNAP, Syno, Netgear, Mac, ASUSTOR, WD (OS5), Linux wkstn/svr, SNAP' Output 'Error: Unknown host. Current supported hosts are: QNAP, Syno, Netgear, Mac, ASUSTOR, WD (OS5), Linux wkstn/svr, SNAP'
Output ' Current supported container images: Plexinc, LinuxServer, HotIO, & BINHEX' Output ' Current supported container images: Plexinc, LinuxServer, HotIO, & BINHEX'
Output ' Manual host configuration is available in most use cases.'
Output ' ' Output ' '
Output 'Are you trying to run the tool from outside the container environment? Manual mode is available. Please see documentation.' Output 'Are you trying to run the tool from outside the container environment? Manual mode is available. Please see documentation.'
exit 1 exit 1
@@ -1807,8 +1819,8 @@ do
# Print info if Manual # Print info if Manual
if [ $ManualConfig -eq 1 ]; then if [ $ManualConfig -eq 1 ]; then
WriteLog "Manual SQLite path: '$PLEX_SQLITE' WriteLog "SQLite path: '$PLEX_SQLITE'"
WriteLog "Manual Database path: '$DBDIR' WriteLog "Database path: '$DBDIR'"
Output " PlexSQLite = '$PLEX_SQLITE'" Output " PlexSQLite = '$PLEX_SQLITE'"
Output " Databases = '$DBDIR'" Output " Databases = '$DBDIR'"
fi fi

View File

@@ -7,16 +7,6 @@
[![master](https://img.shields.io/badge/master-stable-green.svg?maxAge=2592000)]('') [![master](https://img.shields.io/badge/master-stable-green.svg?maxAge=2592000)]('')
![Maintenance](https://img.shields.io/badge/Maintained-Yes-green.svg) ![Maintenance](https://img.shields.io/badge/Maintained-Yes-green.svg)
#### Notice:
10-May-2024: Minor problem with --sqlite option in v1.06.01. Will be fixed in v1.06.02.
All other fuctionality normal.
Sorry for the inconvenience.
# Introduction
DBRepair provides database repair and maintenance for the most common Plex Media Server database problems.
It is a simple menu-driven utility with a command line backend.
DBRepair is run from a command line (terminal or ssh/putty session) which has sufficient privilege to read/write the databases (minimum). DBRepair is run from a command line (terminal or ssh/putty session) which has sufficient privilege to read/write the databases (minimum).
If sufficient privleges exist (root), and supported by the environment, the options to start and stop PMS are presented as well. If sufficient privleges exist (root), and supported by the environment, the options to start and stop PMS are presented as well.
@@ -863,9 +853,13 @@ root@lizum:/sata/plex/Plex Media Server/Plug-in Support/Databases#
Manual configuration is enabled by supplying two command line arguments. Manual configuration is enabled by supplying two command line arguments.
These must precede all other options or commands on the command line. These must precede all other options or commands on the command line.
--sqlite "Directory containing Plex SQLite" (OR) --sqlite "/path/to/Plex SQLite"
Scripted Example: Scripted Example:
DBRepair.sh --sqlite /usr/lib/plexmediaserver --databases /real/host/directory/...../Databases auto prune DBRepair.sh --sqlite /usr/lib/plexmediaserver --databases "/real/host/directory/...../Databases" auto prune
-or-
DBRepair.sh --sqlite "/tmp/plex/Plex SQLite" --databases "/real/host/directory/...../Databases" auto prune
Interactive Example: Interactive Example:

View File

@@ -8,6 +8,18 @@
![Maintenance](https://img.shields.io/badge/Maintained-Yes-green.svg) ![Maintenance](https://img.shields.io/badge/Maintained-Yes-green.svg)
# Release Info: # Release Info:
v1.06.02
1. Bug fix - Fixed incorrect error handling when command line arguments not valid in manual configuration mode.
Fixed incorrect reporting of what was wrong in manual configuration mode.
v1.06.01
1. Manual SQLite path - You many now also specify the full path to "Plex SQLite". ( example: "/tmp/downloads/Plex SQLite")
DBRepair.sh will automatically figure out which form to use (path or directory)
--sqlite "/real/host/path/to/plexmediaserver/Directory"
--sqlite "/real/host/path/to/plexmediaserver/directory/Plex SQLite"
v1.06.00 v1.06.00
1. Manual configuration - You may now run DBRepair from outside container environments. 1. Manual configuration - You may now run DBRepair from outside container environments.