mirror of
https://github.com/ChuckPa/PlexDBRepair.git
synced 2026-02-12 22:16:11 -06:00
Compare commits
1 Commits
ec9edaf304
...
690e89cf57
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
690e89cf57 |
33
CleanPhotoCache-Windows.ps1
Normal file
33
CleanPhotoCache-Windows.ps1
Normal file
@@ -0,0 +1,33 @@
|
||||
param(
|
||||
[Parameter(Mandatory)]
|
||||
[String]$cacheDir,
|
||||
[Int32]$cacheAge=30
|
||||
);
|
||||
|
||||
$cutoff = (Get-Date).AddDays(-$cacheAge);
|
||||
$allFiles = 0;
|
||||
$oldFiles = 0;
|
||||
$freedBytes = 0;
|
||||
Get-ChildItem -Path $cacheDir -Recurse -File |
|
||||
where { $_.extension -in '.jpg','.jpeg','.png','.ppm' } |
|
||||
ForEach {
|
||||
$allFiles++;
|
||||
if ($_.LastWriteTime -lt $cutoff) {
|
||||
$oldFiles++;
|
||||
$freedBytes += $_.Length;
|
||||
Remove-Item $_.FullName;
|
||||
}
|
||||
};
|
||||
|
||||
Write-Output $allFiles;
|
||||
Write-Output $oldFiles;
|
||||
|
||||
if ($freedBytes -gt 1GB) {
|
||||
Write-Output "$([math]::round($freedBytes / 1GB, 2)) GiB";
|
||||
} elseif ($freedBytes -gt 1MB) {
|
||||
Write-Output "$([math]::round($freedBytes / 1MB, 2)) MiB";
|
||||
} elseif ($freedBytes -gt 1KB) {
|
||||
Write-Output "$([math]::round($freedBytes / 1KB, 2)) KiB";
|
||||
} else {
|
||||
Write-Output "$($freedBytes) bytes";
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
@echo off
|
||||
REM PlexDBRepair.bat - Database maintenance / rebuild tool for Windows.
|
||||
REM
|
||||
REM This tool currently works as a "full shot" service.
|
||||
REM This tool currently works as a "full shot" service, outside of PhotoTranscoder pruning.
|
||||
REM - everything is done without need to interact.
|
||||
REM
|
||||
REM -- WARNNING -- WARNING -- WARNING
|
||||
@@ -10,6 +10,26 @@ REM This is stable working software but not "Released" software. Development wi
|
||||
|
||||
setlocal enabledelayedexpansion
|
||||
|
||||
goto :Begin
|
||||
|
||||
:Help
|
||||
echo PlexDBRepair.bat - Database maintenance / rebuild tool for Windows.
|
||||
echo.
|
||||
echo Usage: PlexDBRepair.bat [OPTION]...
|
||||
echo.
|
||||
echo -prune Prune (remove) old image files (jpeg,jpg,png) from PhotoTranscoder
|
||||
echo in addition to standard database maintenance tasks.
|
||||
echo -cacheAge [age] Set the date cutoff for pruned images. Defaults to pruning images
|
||||
echo over 30 days old.
|
||||
echo -skipDB Don't perform database maintenance.
|
||||
echo.
|
||||
echo -- WARNNING -- WARNING -- WARNING
|
||||
echo.
|
||||
echo This is stable working software but not "Released" software. Development will continue.
|
||||
goto :EOF
|
||||
|
||||
:Begin
|
||||
|
||||
REM ### Create Timestamp
|
||||
set Hour=%time:~0,2%
|
||||
set Min=%time:~3,2%
|
||||
@@ -21,14 +41,55 @@ set Hour=%Hour: =%
|
||||
REM ## Set TimeStamp ##
|
||||
set TimeStamp=%Hour%-%Min%-%Sec%
|
||||
|
||||
REM Find PMS database location
|
||||
for /F "tokens=2* skip=2" %%a in ('REG.EXE QUERY "HKCU\Software\Plex, Inc.\Plex Media Server" /v "LocalAppDataPath" 2^> nul') do set "PlexData=%%b\Plex Media Server\Plug-in Support\Databases"
|
||||
if not exist "%PlexData%" (
|
||||
if exist "%LOCALAPPDATA%\Plex Media Server\Plug-in Support\Databases" (
|
||||
set "PlexData=%LOCALAPPDATA%\Plex Media Server\Plug-in Support\Databases"
|
||||
REM Parse arguments
|
||||
set PruneCache=0
|
||||
set CacheAge=30
|
||||
set SkipDBMaintenance=0
|
||||
|
||||
:ParseArgs
|
||||
if "%1" == "" goto :ParseArgsDone
|
||||
|
||||
for %%a in (prune -prune) do if /i "%1" == "%%a" ( set PruneCache=1 ) & shift & goto :ParseArgs
|
||||
for %%a in (cacheage -cacheage) do if /i "%1" == "%%a" ( set "CacheAge=%2" & shift ) & shift & goto :ParseArgs
|
||||
for %%a in (skipdb -skipdb) do if /i "%1" == "%%a" ( set SkipDBMaintenance=1 ) & shift & goto :ParseArgs
|
||||
for %%a in (help -help /? -?) do if /i "%1" == "%%a" goto :Help
|
||||
|
||||
:ParseArgsDone
|
||||
if not "%1" == "" (
|
||||
echo Unknown option "%1"
|
||||
echo.
|
||||
goto :Help
|
||||
)
|
||||
|
||||
REM Find PMS data directory
|
||||
for /F "tokens=2* skip=2" %%a in ('REG.EXE QUERY "HKCU\Software\Plex, Inc.\Plex Media Server" /v "LocalAppDataPath" 2^> nul') do set "AppSupDir=%%b\Plex Media Server"
|
||||
if not exist "%AppSupDir%" (
|
||||
if exist "%LOCALAPPDATA%\Plex Media Server" (
|
||||
set "%AppSupDir%=%LOCALAPPDATA%\Plex Media Server"
|
||||
) else (
|
||||
echo Could not determine Plex database path.
|
||||
echo Normally %LOCALAPPDATA%\Plex Media Server\Plug-in Support\Databases
|
||||
echo Could not determine Plex data directory.
|
||||
echo Normally "%LOCALAPPDATA%\Plex Media Server"
|
||||
echo.
|
||||
goto :EOF
|
||||
)
|
||||
)
|
||||
|
||||
REM Find PMS database location
|
||||
set "PlexData=%AppSupDir%\Plug-in Support\Databases"
|
||||
if not exist "%PlexData%" (
|
||||
echo Could not determine Plex database path.
|
||||
echo Normally %AppSupDir%\Plug-in Support\Databases
|
||||
echo.
|
||||
goto :EOF
|
||||
)
|
||||
|
||||
REM Find PMS cache dir
|
||||
set "PlexCache=%AppSupDir%\Cache\PhotoTranscoder"
|
||||
|
||||
if %PruneCache% == 1 (
|
||||
if not exist "%PlexCache%" (
|
||||
echo Could not determine Plex photo cache path, cannot prune images.
|
||||
echo Normally "%PlexCache%"
|
||||
echo.
|
||||
goto :EOF
|
||||
)
|
||||
@@ -82,6 +143,11 @@ if %ERRORLEVEL%==0 (
|
||||
exit /B 1
|
||||
)
|
||||
|
||||
set "CDSave=%cd%"
|
||||
|
||||
if %SkipDBMaintenance% == 1 (
|
||||
goto :PruneStart
|
||||
)
|
||||
|
||||
cd "%PlexData%"
|
||||
|
||||
@@ -183,6 +249,55 @@ move "%PlexData%\com.plexapp.plugins.library.blobs.db_%TimeStamp%" "%PlexData%\c
|
||||
|
||||
echo %time% -- Database repair/rebuild/reindex completed.
|
||||
echo %time% -- Database repair/rebuild/reindex completed. >> "%PlexData%\PlexDBRepair.log"
|
||||
|
||||
|
||||
:PruneStart
|
||||
if %PruneCache% neq 1 (
|
||||
goto :Done
|
||||
)
|
||||
|
||||
REM Restore working directory
|
||||
cd %CDSave%
|
||||
|
||||
echo %time% -- Prune - START
|
||||
echo %time% -- Prune - START >> "%PlexData%\PlexDBRepair.log"
|
||||
|
||||
REM Validate cache age parameter
|
||||
echo %CacheAge%|findstr /r /c:"^[1-9][0-9]*$" >nul
|
||||
if errorlevel 1 (
|
||||
goto :PruneAgeError
|
||||
) else (
|
||||
set /a "checkZero=%CacheAge%"
|
||||
if "%checkZero%" == 0 (
|
||||
goto :PruneAgeError
|
||||
)
|
||||
)
|
||||
|
||||
goto :Prune
|
||||
|
||||
:PruneAgeError
|
||||
echo %time% -- Prune - ERROR: Cache age %CacheAge% is not a valid value
|
||||
echo %time% -- Prune - ERROR: Cache age %CacheAge% is not a valid value >> "%PlexData%\PlexDBRepair.log"
|
||||
goto :Done
|
||||
|
||||
:Prune
|
||||
|
||||
set i=0
|
||||
for /f "delims=" %%a in ('powershell .\CleanPhotoCache-Windows.ps1 -cacheDir '%PlexCache%' -cacheAge %CacheAge%') do (
|
||||
set PSReturn[!i!]=%%a
|
||||
set /a i += 1
|
||||
)
|
||||
|
||||
set TotalFiles=%PSReturn[0]%
|
||||
set DeletedFiles=%PSReturn[1]%
|
||||
set FreedBytes=%PSReturn[2]%
|
||||
echo %time% -- Prune - Removing %DeletedFiles% files over %CacheAge% days old (out of %TotalFiles% files), freeing %FreedBytes%
|
||||
echo %time% -- Prune - Removing %DeletedFiles% files over %CacheAge% days old (out of %TotalFiles% files), freeing %FreedBytes% >> "%PlexData%\PlexDBRepair.log"
|
||||
|
||||
echo %time% -- Prune - PASS
|
||||
echo %time% -- Prune - PASS >> "%PlexData%\PlexDBRepair.log"
|
||||
|
||||
:Done
|
||||
echo %time% -- ====== Session completed. ======
|
||||
echo %time% -- ====== Session completed. ====== >> "%PlexData%\PlexDBRepair.log"
|
||||
|
||||
|
||||
72
DBRepair.sh
72
DBRepair.sh
@@ -2,12 +2,12 @@
|
||||
#########################################################################
|
||||
# Plex Media Server database check and repair utility script. #
|
||||
# Maintainer: ChuckPa #
|
||||
# Version: v1.06.02 #
|
||||
# Date: 11-May-2024 #
|
||||
# Version: v1.06.00 #
|
||||
# Date: 01-May-2024 #
|
||||
#########################################################################
|
||||
|
||||
# Version for display purposes
|
||||
Version="v1.06.02"
|
||||
Version="v1.06.00"
|
||||
|
||||
# Have the databases passed integrity checks
|
||||
CheckedDB=0
|
||||
@@ -46,8 +46,6 @@ HostType=""
|
||||
LOG_TOOL="echo"
|
||||
ShowMenu=1
|
||||
Exit=0
|
||||
Scripted=0
|
||||
HaveStartStop=0
|
||||
|
||||
# On all hosts except Mac
|
||||
PIDOF="pidof"
|
||||
@@ -375,8 +373,8 @@ HostConfig() {
|
||||
# Manual Config
|
||||
if [ $ManualConfig -eq 1 ]; then
|
||||
|
||||
CACHEDIR="$DBDIR/../../Cache/PhotoTranscoder"
|
||||
LOGFILE="$DBDIR/DBRepair.log"
|
||||
CacheDir="$DBDIR/../../Cache"
|
||||
Logfile="$DBDIR/DBRepair.log"
|
||||
HostType="MANUAL"
|
||||
return 0
|
||||
fi
|
||||
@@ -393,7 +391,7 @@ HostConfig() {
|
||||
# Where is the data
|
||||
AppSuppDir="/var/packages/PlexMediaServer/shares/PlexMediaServer/AppData"
|
||||
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"
|
||||
LOGFILE="$DBDIR/DBRepair.log"
|
||||
|
||||
@@ -423,7 +421,7 @@ HostConfig() {
|
||||
if [ -d "$AppSuppDir/Plex Media Server" ]; then
|
||||
|
||||
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"
|
||||
LOGFILE="$DBDIR/DBRepair.log"
|
||||
|
||||
@@ -448,7 +446,7 @@ HostConfig() {
|
||||
# Where is the data
|
||||
AppSuppDir="$PKGDIR/Library"
|
||||
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"
|
||||
LOGFILE="$DBDIR/DBRepair.log"
|
||||
|
||||
@@ -471,7 +469,7 @@ HostConfig() {
|
||||
# Where things are
|
||||
PLEX_SQLITE="/snap/plexmediaserver/current/Plex SQLite"
|
||||
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"
|
||||
DBDIR="$AppSuppDir/Plex Media Server/Plug-in Support/Databases"
|
||||
LOGFILE="$DBDIR/DBRepair.log"
|
||||
@@ -513,7 +511,7 @@ HostConfig() {
|
||||
fi
|
||||
|
||||
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"
|
||||
LOGFILE="$DBDIR/DBRepair.log"
|
||||
|
||||
@@ -537,7 +535,7 @@ HostConfig() {
|
||||
AppSuppDir="$PKGDIR/MediaLibrary"
|
||||
PID_FILE="$AppSuppDir/Plex Media Server/plexmediaserver.pid"
|
||||
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"
|
||||
LOG_TOOL="logger"
|
||||
|
||||
@@ -558,7 +556,7 @@ HostConfig() {
|
||||
AppSuppDir="/volume1/Plex/Library"
|
||||
PID_FILE="$AppSuppDir/Plex Media Server/plexmediaserver.pid"
|
||||
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"
|
||||
LOG_TOOL="logger"
|
||||
|
||||
@@ -574,7 +572,7 @@ HostConfig() {
|
||||
PLEX_SQLITE="/Applications/Plex Media Server.app/Contents/MacOS/Plex SQLite"
|
||||
AppSuppDir="$HOME/Library/Application Support"
|
||||
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"
|
||||
LOGFILE="$DBDIR/DBRepair.log"
|
||||
LOG_TOOL="logger"
|
||||
@@ -610,7 +608,7 @@ HostConfig() {
|
||||
AppSuppDir="$(echo /mnt/HD/HD*/Nas_Prog/plex_conf)"
|
||||
PID_FILE="$AppSuppDir/Plex Media Server/plexmediaserver.pid"
|
||||
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"
|
||||
LOG_TOOL="logger"
|
||||
|
||||
@@ -630,7 +628,7 @@ HostConfig() {
|
||||
AppSuppDir="/config"
|
||||
PID_FILE="$AppSuppDir/plexmediaserver.pid"
|
||||
DBDIR="$AppSuppDir/Plug-in Support/Databases"
|
||||
CACHEDIR="$AppSuppDir/Plex Media Server/Cache/PhotoTranscoder"
|
||||
CacheDir="$AppSuppDir/Plex Media Server/Cache/PhotoTranscoder"
|
||||
LOGFILE="$DBDIR/DBRepair.log"
|
||||
LOG_TOOL="logger"
|
||||
if [ -d "/run/service/plex" ] || [ -d "/run/service/service-plex" ]; then
|
||||
@@ -650,7 +648,7 @@ HostConfig() {
|
||||
AppSuppDir="/config/Library/Application Support"
|
||||
PID_FILE="$AppSuppDir/Plex Media Server/plexmediaserver.pid"
|
||||
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"
|
||||
LOG_TOOL="logger"
|
||||
@@ -679,7 +677,7 @@ HostConfig() {
|
||||
AppSuppDir="/config"
|
||||
PID_FILE="$AppSuppDir/Plex Media Server/plexmediaserver.pid"
|
||||
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"
|
||||
LOG_TOOL="logger"
|
||||
|
||||
@@ -720,7 +718,7 @@ HostConfig() {
|
||||
fi
|
||||
|
||||
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"
|
||||
LOG_TOOL="logger"
|
||||
HostType="$(grep PRETTY_NAME /etc/os-release | sed -e 's/^.*="//' | tr -d \" )"
|
||||
@@ -1621,7 +1619,7 @@ DoPrunePhotoTranscoder() {
|
||||
PruneIt=1
|
||||
else
|
||||
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
|
||||
[ $FileCount -eq 0 ] && Output "No files found to prune." && return
|
||||
@@ -1636,7 +1634,7 @@ DoPrunePhotoTranscoder() {
|
||||
if [ $PruneIt -eq 1 ]; then
|
||||
Output "Pruning started."
|
||||
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."
|
||||
WriteLog "Prune - PASS."
|
||||
fi
|
||||
@@ -1663,21 +1661,15 @@ do
|
||||
[ "$Opt" = "-f" ] && shift
|
||||
[ "$Opt" = "-p" ] && shift
|
||||
|
||||
# Manual configuration options (running outside of container or unusual hosts)
|
||||
# Manual configuration options (running outside of container)
|
||||
if [ "$Opt" = "--sqlite" ]; then
|
||||
|
||||
# Is this the directory where Plex SQLite exists?
|
||||
if [ -d "$2" ] && [ -f "$2/Plex SQLite" ]; then
|
||||
# Manually specify path to where Plex SQLite is installed.
|
||||
if [ -d "$2" ] && [ -f "$2/Plex SQLite" ]; then
|
||||
PLEX_SQLITE="$2/Plex SQLite"
|
||||
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
|
||||
Output "Given 'Plex SQLite' directory/path ('$2') is invalid. Aborting."
|
||||
exit 2
|
||||
Output "Given directory path ('$1') for Plex SQLite is invalid. Ignoring."
|
||||
fi
|
||||
shift 2
|
||||
fi
|
||||
@@ -1687,18 +1679,15 @@ do
|
||||
# Manual path to databases
|
||||
if [ "$Opt" = "--databases" ]; then
|
||||
|
||||
# Manually specify path to where the databases reside and set all dependent dirs
|
||||
# Manually specify path to where the databases reside
|
||||
if [ -d "$2" ] && [ -f "$2"/com.plexapp.plugins.library.db ]; then
|
||||
DBDIR="$2"
|
||||
AppSuppDir="$(dirname "$(dirname "$(dirname "$DBDIR")")")"
|
||||
CACHEDIR="$AppSuppDir/Plex Media Server/Cache/PhotoTranscoder"
|
||||
LOGFILE="$DBDIR/DBRepair.log"
|
||||
ManualConfig=1
|
||||
|
||||
LOGFILE="$DBDIR/DBRepair.log"
|
||||
AppSuppDir="$( dirname "$(dirname "$(dirname "$db")))")")"
|
||||
|
||||
else
|
||||
Output "Given Plex databases directory ('$2') is invalid. Aborting."
|
||||
exit 2
|
||||
Output "Given directory path ('$1') for Plex databases is invalid. Ignoring."
|
||||
fi
|
||||
shift 2
|
||||
fi
|
||||
@@ -1732,7 +1721,6 @@ Scripted=0
|
||||
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 ' Current supported container images: Plexinc, LinuxServer, HotIO, & BINHEX'
|
||||
Output ' Manual host configuration is available in most use cases.'
|
||||
Output ' '
|
||||
Output 'Are you trying to run the tool from outside the container environment? Manual mode is available. Please see documentation.'
|
||||
exit 1
|
||||
@@ -1819,8 +1807,8 @@ do
|
||||
|
||||
# Print info if Manual
|
||||
if [ $ManualConfig -eq 1 ]; then
|
||||
WriteLog "SQLite path: '$PLEX_SQLITE'"
|
||||
WriteLog "Database path: '$DBDIR'"
|
||||
WriteLog "Manual SQLite path: '$PLEX_SQLITE'
|
||||
WriteLog "Manual Database path: '$DBDIR'
|
||||
Output " PlexSQLite = '$PLEX_SQLITE'"
|
||||
Output " Databases = '$DBDIR'"
|
||||
fi
|
||||
|
||||
70
README.md
70
README.md
@@ -7,6 +7,10 @@
|
||||
[]('')
|
||||

|
||||
|
||||
# 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).
|
||||
If sufficient privleges exist (root), and supported by the environment, the options to start and stop PMS are presented as well.
|
||||
@@ -853,78 +857,14 @@ root@lizum:/sata/plex/Plex Media Server/Plug-in Support/Databases#
|
||||
Manual configuration is enabled by supplying two command line arguments.
|
||||
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:
|
||||
|
||||
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
|
||||
DBRepair.sh --sqlite /usr/lib/plexmediaserver --databases /real/host/directory/...../Databases auto prune
|
||||
|
||||
Interactive Example:
|
||||
|
||||
DBRepair.sh --sqlite /usr/lib/plexmediaserver --databases /real/host/directory/...../Databases
|
||||
|
||||
## Manual Configuration -- Example of using with docker.
|
||||
|
||||
1. I find the SQLite executable
|
||||
```
|
||||
root@Jasper:/mnt/disk1/appdata# find /var/lib/docker -name \*SQLite\*
|
||||
/var/lib/docker/btrfs/subvolumes/4bb78fb70589d4d2ba56754f4d6bc0edd4cdaa8eab7986943767e09a66cefd19/usr/lib/plexmediaserver/Plex SQLite
|
||||
/var/lib/docker/btrfs/subvolumes/eae4fef243ca71fbf190957256705fdc493863ee1f08222a7df0b5004cc8afb6-init/usr/lib/plexmediaserver/Plex SQLite
|
||||
/var/lib/docker/btrfs/subvolumes/eae4fef243ca71fbf190957256705fdc493863ee1f08222a7df0b5004cc8afb6/usr/lib/plexmediaserver/Plex SQLite
|
||||
root@Jasper:/mnt/disk1/appdata#
|
||||
```
|
||||
|
||||
2. I get to where my container is
|
||||
```
|
||||
root@Jasper:~# cd /mnt/user
|
||||
root@Jasper:/mnt/user# ls
|
||||
Media/ appdata/ domains/ isos/ plex/ system/
|
||||
root@Jasper:/mnt/user# cd appdata
|
||||
root@Jasper:/mnt/user/appdata# ls
|
||||
PlexMediaServer/
|
||||
root@Jasper:/mnt/user/appdata# cd PlexMediaServer/
|
||||
```
|
||||
|
||||
3. Invoke DBRepair.sh with both --sqlite and --databases command line options specified (both are required when either is used)
|
||||
```
|
||||
root@Jasper:/mnt/user/appdata/PlexMediaServer# /tmp/DBRepair.sh --databases /mnt/user/appdata/PlexMediaServer/Library/Application\ Support/Plex\ Media\ Server/Plug-in\ Support/Databases/ --sqlite /var/lib/docker/btrfs/subvolumes/4bb78fb70589d4d2ba56754f4d6bc0edd4cdaa8eab7986943767e09a66cefd19/usr/lib/plexmediaserver/
|
||||
|
||||
|
||||
|
||||
Plex Media Server Database Repair Utility (User Defined)
|
||||
Version v1.06.00
|
||||
|
||||
PlexSQLite = '/var/lib/docker/btrfs/subvolumes/4bb78fb70589d4d2ba56754f4d6bc0edd4cdaa8eab7986943767e09a66cefd19/usr/lib/plexmediaserver//Plex SQLite'
|
||||
Databases = '/mnt/user/appdata/PlexMediaServer/Library/Application Support/Plex Media Server/Plug-in Support/Databases/'
|
||||
|
||||
Select
|
||||
|
||||
1 - 'stop' - (Not available. Stop manually.)
|
||||
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' - (Not available. Start manually)
|
||||
|
||||
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) :
|
||||
```
|
||||
|
||||
|
||||
|
||||
# Special considerations - Synology DSM 7
|
||||
|
||||
12
ReleaseNotes
12
ReleaseNotes
@@ -8,18 +8,6 @@
|
||||

|
||||
|
||||
# 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
|
||||
|
||||
1. Manual configuration - You may now run DBRepair from outside container environments.
|
||||
|
||||
Reference in New Issue
Block a user