mirror of
https://github.com/ChuckPa/PlexDBRepair.git
synced 2025-11-06 03:08:55 -05:00
Release 1.0.
New menu w/ command name support Stop containers within the utility Updated documentation
This commit is contained in:
parent
7497df41b2
commit
9b3c0ed40e
162
DBRepair.sh
162
DBRepair.sh
@ -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.0.0 - BETA 2 #
|
# Version: v1.0.0 - RC 1 #
|
||||||
# Date: 26-Feb-2023 #
|
# Date: 05-Mar-2023 #
|
||||||
#########################################################################
|
#########################################################################
|
||||||
|
|
||||||
# Version for display purposes
|
# Version for display purposes
|
||||||
Version="v1.0.0 - BETA 2"
|
Version="v1.0.0 - RC 1"
|
||||||
|
|
||||||
# Flag when temp files are to be retained
|
# Flag when temp files are to be retained
|
||||||
Retain=0
|
Retain=0
|
||||||
@ -31,13 +31,13 @@ CPPL=com.plexapp.plugins.library
|
|||||||
TimeStamp="$(date "+%Y-%m-%d_%H.%M.%S")"
|
TimeStamp="$(date "+%Y-%m-%d_%H.%M.%S")"
|
||||||
|
|
||||||
# Initialize global runtime variables
|
# Initialize global runtime variables
|
||||||
ShowMenu=1
|
|
||||||
CheckedDB=0
|
CheckedDB=0
|
||||||
Damaged=0
|
Damaged=0
|
||||||
Fail=0
|
Fail=0
|
||||||
HaveStartStop=0
|
HaveStartStop=0
|
||||||
HostType=""
|
HostType=""
|
||||||
LOG_TOOL="echo"
|
LOG_TOOL="echo"
|
||||||
|
ShowMenu=1
|
||||||
|
|
||||||
# Universal output function
|
# Universal output function
|
||||||
Output() {
|
Output() {
|
||||||
@ -136,7 +136,7 @@ GetDates(){
|
|||||||
Tempfile="/tmp/DBRepairTool.$$.tmp"
|
Tempfile="/tmp/DBRepairTool.$$.tmp"
|
||||||
touch "$Tempfile"
|
touch "$Tempfile"
|
||||||
|
|
||||||
for i in $(find . -maxdepth 0 -name 'com.plexapp.plugins.library.db-????-??-??' | sort -r)
|
for i in $(find . -maxdepth 1 -name 'com.plexapp.plugins.library.db-????-??-??' | sort -r)
|
||||||
do
|
do
|
||||||
# echo Date - "${i//[^.]*db-/}"
|
# echo Date - "${i//[^.]*db-/}"
|
||||||
Date="$(echo $i | sed -e 's/.*.db-//')"
|
Date="$(echo $i | sed -e 's/.*.db-//')"
|
||||||
@ -265,29 +265,6 @@ ConfirmYesNo() {
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# If no, done.
|
|
||||||
if [ "$Answer" = "N" ]; then
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# User said Yes. Be 100% certain
|
|
||||||
Answer=""
|
|
||||||
while [ "$Answer" = "" ]
|
|
||||||
do
|
|
||||||
printf "Are you sure (Y/N) ? "
|
|
||||||
read Input
|
|
||||||
|
|
||||||
# EOF = No
|
|
||||||
[ "$Input" = "" ] && Answer=N ; [ "$Input" = "n" ] && Answer=N ; [ "$Input" = "N" ] && Answer=N
|
|
||||||
[ "$Input" = "y" ] && Answer=Y ; [ "$Input" = "Y" ] && Answer=Y
|
|
||||||
|
|
||||||
# Unrecognized
|
|
||||||
if [ "$Answer" != "Y" ] && [ "$Answer" != "N" ]; then
|
|
||||||
echo "$Input" was not a valid reply. Please try again.
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
if [ "$Answer" = "Y" ]; then
|
if [ "$Answer" = "Y" ]; then
|
||||||
# Confirmed Yes
|
# Confirmed Yes
|
||||||
return 0
|
return 0
|
||||||
@ -540,7 +517,7 @@ HostConfig() {
|
|||||||
return 0
|
return 0
|
||||||
|
|
||||||
# BINHEX Plex image
|
# BINHEX Plex image
|
||||||
elif [ -d "/config/Plex Media Server" ]; then
|
elif [-f /usr/lib/python3.10/binhex.py ] && [ -d "/config/Plex Media Server" ]; then
|
||||||
|
|
||||||
PLEX_SQLITE="/usr/lib/plexmediaserver/Plex SQLite"
|
PLEX_SQLITE="/usr/lib/plexmediaserver/Plex SQLite"
|
||||||
AppSuppDir="/config"
|
AppSuppDir="/config"
|
||||||
@ -690,12 +667,12 @@ DoUndo(){
|
|||||||
if [ "$LastTimestamp" != "" ]; then
|
if [ "$LastTimestamp" != "" ]; then
|
||||||
|
|
||||||
# Educate user
|
# Educate user
|
||||||
echo " "
|
echo ""
|
||||||
echo "'Undo' restores the databases to the state prior to the last SUCCESSFUL action."
|
echo "'Undo' restores the databases to the state prior to the last SUCCESSFUL action."
|
||||||
echo "If any action fails before it completes, that action is automatically undone for you."
|
echo "If any action fails before it completes, that action is automatically undone for you."
|
||||||
echo "Be advised: Undo restores the databases to their state PRIOR TO the last action of 'Vacuum', 'Reindex', or 'Replace'"
|
echo "Be advised: Undo restores the databases to their state PRIOR TO the last action of 'Vacuum', 'Reindex', or 'Replace'"
|
||||||
echo "WARNING: Once Undo completes, there will be nothing more to Undo untl another successful action is completed"
|
echo "WARNING: Once Undo completes, there will be nothing more to Undo untl another successful action is completed"
|
||||||
echo " "
|
echo ""
|
||||||
|
|
||||||
if ConfirmYesNo "Undo '$LastName' performed at timestamp '$LastTimestamp' ? "; then
|
if ConfirmYesNo "Undo '$LastName' performed at timestamp '$LastTimestamp' ? "; then
|
||||||
|
|
||||||
@ -814,7 +791,7 @@ DoRepair() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Made it to here, now verify
|
# Made it to here, now verify
|
||||||
Output "Successfully imported data from SQL files."
|
Output "Successfully imported SQL data."
|
||||||
WriteLog "Repair - Import - PASS"
|
WriteLog "Repair - Import - PASS"
|
||||||
|
|
||||||
# Verify databases are intact and pass testing
|
# Verify databases are intact and pass testing
|
||||||
@ -851,16 +828,13 @@ DoRepair() {
|
|||||||
[ -e $CPPL.db ] && mv $CPPL.db "$TMPDIR/$CPPL.db-BACKUP-$TimeStamp"
|
[ -e $CPPL.db ] && mv $CPPL.db "$TMPDIR/$CPPL.db-BACKUP-$TimeStamp"
|
||||||
[ -e $CPPL.blobs.db ] && mv $CPPL.blobs.db "$TMPDIR/$CPPL.blobs.db-BACKUP-$TimeStamp"
|
[ -e $CPPL.blobs.db ] && mv $CPPL.blobs.db "$TMPDIR/$CPPL.blobs.db-BACKUP-$TimeStamp"
|
||||||
|
|
||||||
Output "Making imported databases active"
|
Output "Making repaired databases active"
|
||||||
mv "$TMPDIR/$CPPL.db-REPAIR-$TimeStamp" $CPPL.db
|
mv "$TMPDIR/$CPPL.db-REPAIR-$TimeStamp" $CPPL.db
|
||||||
mv "$TMPDIR/$CPPL.blobs.db-REPAIR-$TimeStamp" $CPPL.blobs.db
|
mv "$TMPDIR/$CPPL.blobs.db-REPAIR-$TimeStamp" $CPPL.blobs.db
|
||||||
|
|
||||||
Output "Import complete. Please check your library settings and contents for completeness."
|
Output "Repair complete. Please check your library settings and contents for completeness."
|
||||||
Output "Recommend: Scan Files and Refresh all metadata for each library section."
|
Output "Recommend: Scan Files and Refresh all metadata for each library section."
|
||||||
|
|
||||||
# Remove .sql temp files from $TMPDIR
|
|
||||||
# rm -f "$TMPDIR"/*.sql-*
|
|
||||||
|
|
||||||
# Ensure WAL and SHM are gone
|
# Ensure WAL and SHM are gone
|
||||||
[ -e $CPPL.blobs.db-wal ] && rm -f $CPPL.blobs.db-wal
|
[ -e $CPPL.blobs.db-wal ] && rm -f $CPPL.blobs.db-wal
|
||||||
[ -e $CPPL.blobs.db-shm ] && rm -f $CPPL.blobs.db-shm
|
[ -e $CPPL.blobs.db-shm ] && rm -f $CPPL.blobs.db-shm
|
||||||
@ -880,8 +854,8 @@ DoRepair() {
|
|||||||
return 0
|
return 0
|
||||||
else
|
else
|
||||||
|
|
||||||
rm -f "$TMPDIR/$CPPL.db-IMPORT-$TimeStamp"
|
rm -f "$TMPDIR/$CPPL.db-REPAIR-$TimeStamp"
|
||||||
rm -f "$TMPDIR/$CPPL.blobs.db-IMPORT-$TimeStamp"
|
rm -f "$TMPDIR/$CPPL.blobs.db-REPAIR-$TimeStamp"
|
||||||
|
|
||||||
Output "Repair has failed. No files changed"
|
Output "Repair has failed. No files changed"
|
||||||
WriteLog "Repair - $TimeStamp - FAIL"
|
WriteLog "Repair - $TimeStamp - FAIL"
|
||||||
@ -918,6 +892,13 @@ DoReplace() {
|
|||||||
Output "Checking for a usable backup."
|
Output "Checking for a usable backup."
|
||||||
Candidate=""
|
Candidate=""
|
||||||
|
|
||||||
|
# Make certain there is ample free space
|
||||||
|
if ! FreeSpaceAvailable ; then
|
||||||
|
Output "ERROR: Insufficient free space available on $AppSuppDir. Cannot continue
|
||||||
|
WriteLog "REPLACE - Insufficient free space available on $AppSuppDir. Aborted.
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
Output "Database backups available are: $Dates"
|
Output "Database backups available are: $Dates"
|
||||||
for i in $Dates
|
for i in $Dates
|
||||||
do
|
do
|
||||||
@ -952,7 +933,7 @@ DoReplace() {
|
|||||||
# Copy this backup into position as primary
|
# Copy this backup into position as primary
|
||||||
Output "Copying backup database $Candidate to use as new database."
|
Output "Copying backup database $Candidate to use as new database."
|
||||||
|
|
||||||
cp -p $CPPL.db-$Candidate $CPPL.db-$TimeStamp
|
cp -p $CPPL.db-$Candidate $CPPL.db-REPLACE-$TimeStamp
|
||||||
Result=$?
|
Result=$?
|
||||||
|
|
||||||
if [ $Result -ne 0 ]; then
|
if [ $Result -ne 0 ]; then
|
||||||
@ -964,7 +945,7 @@ DoReplace() {
|
|||||||
WriteLog "Replace - Copy $CPPL.db-$i - PASS"
|
WriteLog "Replace - Copy $CPPL.db-$i - PASS"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cp -p $CPPL.blobs.db-$Candidate $CPPL.blobs.db-$TimeStamp
|
cp -p $CPPL.blobs.db-$Candidate $CPPL.blobs.db-REPLACE-$TimeStamp
|
||||||
Result=$?
|
Result=$?
|
||||||
|
|
||||||
if [ $Result -ne 0 ]; then
|
if [ $Result -ne 0 ]; then
|
||||||
@ -981,12 +962,12 @@ DoReplace() {
|
|||||||
# Final checks
|
# Final checks
|
||||||
Output "Copy complete. Performing final check"
|
Output "Copy complete. Performing final check"
|
||||||
|
|
||||||
if CheckDB $CPPL.db-$TimeStamp && \
|
if CheckDB $CPPL.db-REPLACE-$TimeStamp && \
|
||||||
CheckDB $CPPL.blobs.db-$TimeStamp ; then
|
CheckDB $CPPL.blobs.db-REPLACE-$TimeStamp ; then
|
||||||
|
|
||||||
# Move into position as active
|
# Move into position as active
|
||||||
mv $CPPL.db-$TimeStamp $CPPL.db
|
mv $CPPL.db-REPLACE-$TimeStamp $CPPL.db
|
||||||
mv $CPPL.blobs.db-$TimeStamp $CPPL.blobs.db
|
mv $CPPL.blobs.db-REPLACE-$TimeStamp $CPPL.blobs.db
|
||||||
|
|
||||||
# done
|
# done
|
||||||
Output "Database recovery and verification complete."
|
Output "Database recovery and verification complete."
|
||||||
@ -1050,7 +1031,6 @@ DoVacuum(){
|
|||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
# Make a backup
|
# Make a backup
|
||||||
Output "Backing up databases"
|
Output "Backing up databases"
|
||||||
if ! MakeBackups "Vacuum "; then
|
if ! MakeBackups "Vacuum "; then
|
||||||
@ -1111,6 +1091,12 @@ DoVacuum(){
|
|||||||
##### (import) Viewstate/Watch history from another DB and import
|
##### (import) Viewstate/Watch history from another DB and import
|
||||||
DoImport(){
|
DoImport(){
|
||||||
|
|
||||||
|
if ! FreeSpaceAvailable; then
|
||||||
|
Output "Unable to make backups before importing. Insufficient free space available on $AppSuppDir."
|
||||||
|
WriteLog "Import - Insufficient free disk space for backups."
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
printf "Pathname of database containing watch history to import: "
|
printf "Pathname of database containing watch history to import: "
|
||||||
read Input
|
read Input
|
||||||
|
|
||||||
@ -1123,7 +1109,7 @@ DoImport(){
|
|||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
Output " "
|
Output ""
|
||||||
WriteLog "Import - Attempting to import watch history from '$Input' "
|
WriteLog "Import - Attempting to import watch history from '$Input' "
|
||||||
|
|
||||||
# Confirm our databases are intact
|
# Confirm our databases are intact
|
||||||
@ -1182,13 +1168,13 @@ DoImport(){
|
|||||||
printf 'Importing Viewstate & History data...'
|
printf 'Importing Viewstate & History data...'
|
||||||
"$PLEX_SQLITE" "$TMPDIR/$CPPL.db-IMPORT-$TimeStamp" < "$TMPDIR/Viewstate.sql-$TimeStamp" 2> /dev/null
|
"$PLEX_SQLITE" "$TMPDIR/$CPPL.db-IMPORT-$TimeStamp" < "$TMPDIR/Viewstate.sql-$TimeStamp" 2> /dev/null
|
||||||
|
|
||||||
# Purge duplicates (violations of unique constraint)
|
# # Purge duplicates (violations of unique constraint)
|
||||||
cat <<EOF | "$PLEX_SQLITE" "$TMPDIR/$CPPL.db-IMPORT-$TimeStamp"
|
# cat <<EOF | "$PLEX_SQLITE" "$TMPDIR/$CPPL.db-IMPORT-$TimeStamp"
|
||||||
DELETE FROM metadata_item_settings
|
# DELETE FROM metadata_item_settings
|
||||||
WHERE id in (SELECT MIN(id)
|
# WHERE id in (SELECT MIN(id)
|
||||||
FROM metadata_item_settings
|
# FROM metadata_item_settings
|
||||||
GROUP BY guid HAVING COUNT(guid) > 1);
|
# GROUP BY guid HAVING COUNT(guid) > 1);
|
||||||
EOF
|
#EOF
|
||||||
|
|
||||||
# Make certain the resultant DB is OK
|
# Make certain the resultant DB is OK
|
||||||
Output " done."
|
Output " done."
|
||||||
@ -1383,15 +1369,17 @@ do
|
|||||||
echo " Version $Version"
|
echo " Version $Version"
|
||||||
echo " "
|
echo " "
|
||||||
|
|
||||||
# Main menu loop
|
|
||||||
Choice=0; Exit=0; NullCommands=0
|
Choice=0; Exit=0; NullCommands=0
|
||||||
|
|
||||||
|
# Main menu loop
|
||||||
while [ $Choice -eq 0 ]
|
while [ $Choice -eq 0 ]
|
||||||
do
|
do
|
||||||
if [ $ShowMenu -eq 1 ] && [ $Scripted -eq 0 ]; then
|
if [ $ShowMenu -eq 1 ] && [ $Scripted -eq 0 ]; then
|
||||||
|
|
||||||
echo " "
|
echo ""
|
||||||
echo "Select"
|
echo "Select"
|
||||||
echo " "
|
echo ""
|
||||||
[ $HaveStartStop -gt 0 ] && echo " 1 - 'stop' - Stop PMS"
|
[ $HaveStartStop -gt 0 ] && echo " 1 - 'stop' - Stop PMS"
|
||||||
[ $HaveStartStop -eq 0 ] && echo " 1 - 'stop' - (Not available. Stop manually)"
|
[ $HaveStartStop -eq 0 ] && echo " 1 - 'stop' - (Not available. Stop manually)"
|
||||||
echo " 2 - 'automatic' - database check, repair/optimize, and reindex in one step."
|
echo " 2 - 'automatic' - database check, repair/optimize, and reindex in one step."
|
||||||
@ -1402,16 +1390,18 @@ do
|
|||||||
|
|
||||||
[ $HaveStartStop -gt 0 ] && echo " 7 - 'start' - Start PMS"
|
[ $HaveStartStop -gt 0 ] && echo " 7 - 'start' - Start PMS"
|
||||||
[ $HaveStartStop -eq 0 ] && echo " 7 - 'start' - (Not available. Start manually)"
|
[ $HaveStartStop -eq 0 ] && echo " 7 - 'start' - (Not available. Start manually)"
|
||||||
echo " 8 - 'replace' - Replace current databases with newest usable backup copy (interactive)"
|
echo ""
|
||||||
echo " 9 - 'show' - Show logfile"
|
echo " 8 - 'import' - Import watch history from another database independent of Plex. (risky)"
|
||||||
echo " 10 - 'status' - Report status of PMS (run-state and databases)"
|
echo " 9 - 'replace' - Replace current databases with newest usable backup copy (interactive)"
|
||||||
echo " 11 - 'undo' - Undo last successful command"
|
echo " 10 - 'show' - Show logfile"
|
||||||
|
echo " 11 - 'status' - Report status of PMS (run-state and databases)"
|
||||||
|
echo " 12 - 'undo' - Undo last successful command"
|
||||||
|
echo ""
|
||||||
|
|
||||||
echo " 99 - exit"
|
echo " 99 - exit"
|
||||||
fi
|
fi
|
||||||
if [ $Scripted -eq 0 ]; then
|
if [ $Scripted -eq 0 ]; then
|
||||||
echo " "
|
echo ""
|
||||||
printf "Enter command # -or- command name (4 char min) : "
|
printf "Enter command # -or- command name (4 char min) : "
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -1453,6 +1443,7 @@ do
|
|||||||
DoStop
|
DoStop
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
|
||||||
# Automatic of all common operations
|
# Automatic of all common operations
|
||||||
2|auto*)
|
2|auto*)
|
||||||
|
|
||||||
@ -1480,7 +1471,7 @@ do
|
|||||||
WriteLog "Auto - START"
|
WriteLog "Auto - START"
|
||||||
|
|
||||||
# Check the databases (forced)
|
# Check the databases (forced)
|
||||||
Output " "
|
Output ""
|
||||||
if CheckDatabases "Check " force ; then
|
if CheckDatabases "Check " force ; then
|
||||||
WriteLog "Check - PASS"
|
WriteLog "Check - PASS"
|
||||||
CheckedDB=1
|
CheckedDB=1
|
||||||
@ -1490,7 +1481,7 @@ do
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Now Repair
|
# Now Repair
|
||||||
Output " "
|
Output ""
|
||||||
if ! DoRepair; then
|
if ! DoRepair; then
|
||||||
|
|
||||||
WriteLog "Repair - FAIL"
|
WriteLog "Repair - FAIL"
|
||||||
@ -1506,7 +1497,7 @@ do
|
|||||||
|
|
||||||
# Now Index
|
# Now Index
|
||||||
DoUpdateTimestamp
|
DoUpdateTimestamp
|
||||||
Output " "
|
Output ""
|
||||||
if ! DoIndex; then
|
if ! DoIndex; then
|
||||||
WriteLog "Index - FAIL"
|
WriteLog "Index - FAIL"
|
||||||
WriteLog "Auto - FAIL"
|
WriteLog "Auto - FAIL"
|
||||||
@ -1519,11 +1510,11 @@ do
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# All good to here
|
# All good to here
|
||||||
WriteLog "Auto - PASS"
|
WriteLog "Auto - COMPLETED"
|
||||||
Output "Automatic Check,Repair/optimize,Index successful."
|
Output "Automatic Check, Repair/optimize, & Index successful."
|
||||||
|
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
|
||||||
# Check databases
|
# Check databases
|
||||||
3|chec*)
|
3|chec*)
|
||||||
|
|
||||||
@ -1580,6 +1571,7 @@ do
|
|||||||
DoRepair
|
DoRepair
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
|
||||||
# Index databases
|
# Index databases
|
||||||
6|rein*|inde*)
|
6|rein*|inde*)
|
||||||
|
|
||||||
@ -1614,6 +1606,7 @@ do
|
|||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
|
||||||
# Start PMS (if available this host)
|
# Start PMS (if available this host)
|
||||||
7|star*)
|
7|star*)
|
||||||
|
|
||||||
@ -1633,8 +1626,16 @@ do
|
|||||||
[ "$Option" = "no" ] && ShowMenu=0 && echo menu off: Reenable with \'menu on\' command
|
[ "$Option" = "no" ] && ShowMenu=0 && echo menu off: Reenable with \'menu on\' command
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
|
||||||
|
# Import watch history
|
||||||
|
8|impo*)
|
||||||
|
|
||||||
|
DoImport
|
||||||
|
;;
|
||||||
|
|
||||||
|
|
||||||
# Replace (from PMS backup)
|
# Replace (from PMS backup)
|
||||||
8|repl*)
|
9|repl*)
|
||||||
|
|
||||||
# Check if PMS running
|
# Check if PMS running
|
||||||
if IsRunning; then
|
if IsRunning; then
|
||||||
@ -1653,18 +1654,20 @@ do
|
|||||||
DoReplace
|
DoReplace
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
|
||||||
# Show loggfile
|
# Show loggfile
|
||||||
9|show*)
|
10|show*)
|
||||||
|
|
||||||
echo ==================================================================================
|
echo ==================================================================================
|
||||||
cat "$LOGFILE"
|
cat "$LOGFILE"
|
||||||
echo ==================================================================================
|
echo ==================================================================================
|
||||||
;;
|
;;
|
||||||
|
|
||||||
# Current status of Plex and databases
|
|
||||||
10|stat*)
|
|
||||||
|
|
||||||
Output " "
|
# Current status of Plex and databases
|
||||||
|
11|stat*)
|
||||||
|
|
||||||
|
Output ""
|
||||||
Output "Status report: $(date)"
|
Output "Status report: $(date)"
|
||||||
if IsRunning ; then
|
if IsRunning ; then
|
||||||
Output " PMS is running."
|
Output " PMS is running."
|
||||||
@ -1675,11 +1678,12 @@ do
|
|||||||
[ $CheckedDB -eq 0 ] && Output " Databases are not checked, Status unknown."
|
[ $CheckedDB -eq 0 ] && Output " Databases are not checked, Status unknown."
|
||||||
[ $CheckedDB -eq 1 ] && [ $Damaged -eq 0 ] && Output " Databases are OK."
|
[ $CheckedDB -eq 1 ] && [ $Damaged -eq 0 ] && Output " Databases are OK."
|
||||||
[ $CheckedDB -eq 1 ] && [ $Damaged -eq 1 ] && Output " Databases were checked and are damaged."
|
[ $CheckedDB -eq 1 ] && [ $Damaged -eq 1 ] && Output " Databases were checked and are damaged."
|
||||||
Output " "
|
Output ""
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
|
||||||
# Undo
|
# Undo
|
||||||
11|undo*)
|
12|undo*)
|
||||||
|
|
||||||
DoUndo
|
DoUndo
|
||||||
;;
|
;;
|
||||||
@ -1697,8 +1701,7 @@ do
|
|||||||
# Ask questions on interactive exit
|
# Ask questions on interactive exit
|
||||||
if [ $Exit -eq 0 ]; then
|
if [ $Exit -eq 0 ]; then
|
||||||
# Ask if the user wants to remove the DBTMP directory and all backups thus far
|
# Ask if the user wants to remove the DBTMP directory and all backups thus far
|
||||||
if ConfirmYesNo "Ok to remove temporary databases/workfiles for this session?" ; then
|
if [ "$Input" = "exit" ] && ConfirmYesNo "Ok to remove temporary databases/workfiles for this session?" ; then
|
||||||
|
|
||||||
# There it goes
|
# There it goes
|
||||||
Output "Deleting all temporary work files."
|
Output "Deleting all temporary work files."
|
||||||
WriteLog "Exit - Delete temp files."
|
WriteLog "Exit - Delete temp files."
|
||||||
@ -1720,9 +1723,10 @@ do
|
|||||||
|
|
||||||
# Unknown command
|
# Unknown command
|
||||||
*)
|
*)
|
||||||
WriteLog "Unknown: '$Input'"
|
WriteLog "Unknown command: '$Input'"
|
||||||
Output "ERROR: Unknown command: '$Input'"
|
Output "ERROR: Unknown command: '$Input'"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
|
|||||||
325
README.md
325
README.md
@ -103,10 +103,10 @@ It is a simple menu-driven utility with a command line backend.
|
|||||||
Synology (DSM 6) | Plex | /volume1/Plex (change volume as required)
|
Synology (DSM 6) | Plex | /volume1/Plex (change volume as required)
|
||||||
Synology (DSM 7) | PlexMediaServer | /volume1/PlexMediaServer (change volume as required)
|
Synology (DSM 7) | PlexMediaServer | /volume1/PlexMediaServer (change volume as required)
|
||||||
Western Digital | Public | /mnt/HD/HD_a2/Public (Does not support 'MyCloudHome' series)
|
Western Digital | Public | /mnt/HD/HD_a2/Public (Does not support 'MyCloudHome' series)
|
||||||
|
```
|
||||||
|
|
||||||
### General installation and usage instructions
|
### General installation and usage instructions
|
||||||
```
|
|
||||||
1. Open your browser to https://github.com/ChuckPa/PlexDBRepair/releases/latest
|
1. Open your browser to https://github.com/ChuckPa/PlexDBRepair/releases/latest
|
||||||
2. Download the source code (tar.gz or ZIP) file
|
2. Download the source code (tar.gz or ZIP) file
|
||||||
|
|
||||||
@ -120,75 +120,61 @@ It is a simple menu-driven utility with a command line backend.
|
|||||||
9. Give DBRepair.sh 'execute' permission (chmod +x)
|
9. Give DBRepair.sh 'execute' permission (chmod +x)
|
||||||
10. Invoke ./DBRepair.sh
|
10. Invoke ./DBRepair.sh
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
### EXAMPLE: To install & launch on Synology DSM 6
|
### EXAMPLE: To install & launch on Synology DSM 6
|
||||||
```
|
|
||||||
cd /volume1/Plex
|
cd /volume1/Plex
|
||||||
sudo bash
|
sudo bash
|
||||||
tar xf PlexDBRepair-x.y.z.tar.gz
|
tar xf PlexDBRepair-x.y.z.tar.gz
|
||||||
cd PlexDBRepair-x.y.z
|
cd PlexDBRepair-x.y.z
|
||||||
chmod +x DBRepair.sh
|
chmod +x DBRepair.sh
|
||||||
./DBRepair.sh
|
./DBRepair.sh
|
||||||
```
|
|
||||||
|
|
||||||
### EXAMPLE: Using DBRepair inside containers (manual start/stop included)
|
### EXAMPLE: Using DBRepair inside containers (manual start/stop included)
|
||||||
|
|
||||||
#### (Select containers allow stopping/starting PMS from the menu. See menu for details)
|
#### (Select containers allow stopping/starting PMS from the menu. See menu for details)
|
||||||
```
|
|
||||||
sudo docker exec -it plex /bin/bash
|
sudo docker exec -it plex /bin/bash
|
||||||
|
|
||||||
# Stop Plex manually when using official Plex,inc image
|
|
||||||
/plex_service.sh -d
|
|
||||||
--or--
|
|
||||||
# Stop Plex manually when using Linuxserver.io Plex image
|
|
||||||
s6-svc -d /var/run/service/svc-plex
|
|
||||||
--or--
|
|
||||||
# Stop Plex manually in binhex containers
|
|
||||||
kill -15 $(pidof 'Plex Media Server')
|
|
||||||
--or--
|
|
||||||
# Stop Plex manually in HOTIO containers
|
|
||||||
s6-svc -d /run/service/plex
|
|
||||||
|
|
||||||
|
|
||||||
# extract from downloaded version file name then cd into directory
|
# extract from downloaded version file name then cd into directory
|
||||||
tar xf PlexDBRepair-0.6.4.tar.gz
|
tar xf PlexDBRepair-1.0.0.tar.gz
|
||||||
cd PlexDBRepair-0.6.4
|
cd PlexDBRepair-1.0.0
|
||||||
chmod +x DBRepair.sh
|
chmod +x DBRepair.sh
|
||||||
./DBRepair.sh
|
./DBRepair.sh
|
||||||
```
|
```
|
||||||
### EXAMPLE: Using DBRepair on regular Linux native host (Workstation/Server)
|
### EXAMPLE: Using DBRepair on regular Linux native host (Workstation/Server)
|
||||||
```
|
```
|
||||||
sudo bash
|
sudo bash
|
||||||
systemctl stop plexmediaserver
|
|
||||||
cd /path/to/DBRepair.tar
|
cd /path/to/DBRepair.tar
|
||||||
tar xf PlexDBRepair-0.6.1.tar.gz
|
tar xf PlexDBRepair-1.0.0.tar.gz
|
||||||
cd PlexDBRepair-0.6.1
|
cd PlexDBRepair-1.0.0
|
||||||
chmod +x DBRepair.sh
|
chmod +x DBRepair.sh
|
||||||
./DBRepair.sh
|
./DBRepair.sh stop auto start exit
|
||||||
```
|
```
|
||||||
|
|
||||||
### EXAMPLE: Using DBRepair from the command line on MacOS (on the administrator account)
|
### EXAMPLE: Using DBRepair from the command line on MacOS (on the administrator account)
|
||||||
```
|
```
|
||||||
osascript -e 'quit app "Plex Media Server"'
|
osascript -e 'quit app "Plex Media Server"'
|
||||||
cd ~/Downloads
|
cd ~/Downloads
|
||||||
tar xvf PlexDBRepai PlexDBRepair-0.6.1.tar.gz
|
tar xvf PlexDBRepai PlexDBRepair-1.0.0.tar.gz
|
||||||
cd PlexDBRepai PlexDBRepair-0.6.1
|
cd PlexDBRepai PlexDBRepair-1.0.0
|
||||||
|
|
||||||
chmod +x DBRepair.sh
|
chmod +x DBRepair.sh
|
||||||
./DBRepair.sh
|
./DBRepair.sh
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
## Typical usage
|
## Typical usage
|
||||||
```
|
|
||||||
This utility can only operate on PMS when PMS is in the stopped state.
|
This utility can only operate on PMS when PMS is in the stopped state.
|
||||||
If PMS is running when you startup the utility, it will tell you.
|
If PMS is running when you startup the utility, it will tell you.
|
||||||
|
|
||||||
These examples
|
These examples
|
||||||
|
|
||||||
A. The most common usage will be the "Automatic" function.
|
A. The most common usage will be the "Automatic" function.
|
||||||
|
|
||||||
Automatic mode is where DBRepair determines which steps are needed to make your database run optimally.
|
Automatic mode is where DBRepair determines which steps are needed to make your database run optimally.
|
||||||
For most users, Automatic is equivalent to 'Check, Repair, Reindex'.
|
For most users, Automatic is equivalent to 'Check, Repair, Reindex'.
|
||||||
@ -242,7 +228,7 @@ Special considerations:
|
|||||||
- ALL database temps are named with date-time stamps in the name to avoid confusion.
|
- ALL database temps are named with date-time stamps in the name to avoid confusion.
|
||||||
4. The Logfile ('show' command) shows all actions performed WITH timestamp so you can locate intermediate databases
|
4. The Logfile ('show' command) shows all actions performed WITH timestamp so you can locate intermediate databases
|
||||||
if desired for special / manual recovery cases.
|
if desired for special / manual recovery cases.
|
||||||
```
|
|
||||||
|
|
||||||
## Scripting support
|
## Scripting support
|
||||||
|
|
||||||
@ -267,34 +253,14 @@ Special considerations:
|
|||||||
You'll be able to ask in the Plex forums about what to do. Be prepared to present the log file to them.
|
You'll be able to ask in the Plex forums about what to do. Be prepared to present the log file to them.
|
||||||
|
|
||||||
|
|
||||||
## Sample session
|
## Sample interactive session
|
||||||
|
|
||||||
|
This is a typical manual session if you aren't sure what to do and want the tool to decide.
|
||||||
|
|
||||||
|
|
||||||
This sample session shows all the features present. You won't use :
|
|
||||||
1. PMS exclusive access to the databases interlock protecting your data
|
|
||||||
2. Basic checks, vacuum, and reindex
|
|
||||||
3. Full export/import (repair) which also reloads the database in perfect order
|
|
||||||
4. Importing viewstate (watch history) data from another database (an older backup)
|
|
||||||
5. What the log file details for you.
|
|
||||||
|
|
||||||
|
|
||||||
```
|
```
|
||||||
bash-4.4# pwd
|
bash-4.4# #=======================================================================================================
|
||||||
/volume1/Plex
|
|
||||||
bash-4.4# ./DBRepair.sh
|
|
||||||
Plex Media Server is currently running, cannot continue.
|
|
||||||
Please stop Plex Media Server and restart this utility.
|
|
||||||
bash-4.4# ./DBRepair.sh
|
|
||||||
Plex Media Server is currently running, cannot continue.
|
|
||||||
Please stop Plex Media Server and restart this utility.
|
|
||||||
bash-4.4# ./DBRepair.sh
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
=======================================================================================================
|
|
||||||
bash-4.4# ./DBRepair.sh
|
bash-4.4# ./DBRepair.sh
|
||||||
|
|
||||||
|
|
||||||
@ -305,18 +271,20 @@ bash-4.4# ./DBRepair.sh
|
|||||||
|
|
||||||
Select
|
Select
|
||||||
|
|
||||||
1 - 'stop' PMS
|
1 - 'stop' - Stop PMS
|
||||||
2 - 'automatic' database check, repair/optimize, and reindex in one step.
|
2 - 'automatic' - database check, repair/optimize, and reindex in one step.
|
||||||
3 - 'check' database
|
3 - 'check' - Perform integrity check of database
|
||||||
4 - 'vacuum' database
|
4 - 'vacuum' - Remove empty space from database
|
||||||
5 - 'repair' / 'optimize' database
|
5 - 'repair' - Repair/Optimize databases
|
||||||
6 - 'reindex' database
|
6 - 'reindex' - Rebuild database database indexes
|
||||||
7 - 'start' PMS
|
7 - 'start' - Start PMS
|
||||||
8 - 'import' viewstate (Watch history) from another PMS database
|
|
||||||
9 - 'replace' current database with newest usable backup copy (interactive)
|
8 - 'import' - Import watch history from another database independent of Plex. (risky)
|
||||||
10 - 'show' logfile
|
9 - 'replace' - Replace current databases with newest usable backup copy (interactive)
|
||||||
11 - 'status' of PMS (Stop/Run and databases)
|
10 - 'show' - Show logfile
|
||||||
12 - 'undo' - Undo last successful command
|
11 - 'status' - Report status of PMS (run-state and databases)
|
||||||
|
12 - 'undo' - Undo last successful command
|
||||||
|
|
||||||
99 - exit
|
99 - exit
|
||||||
|
|
||||||
Enter command # -or- command name (4 char min) : 1
|
Enter command # -or- command name (4 char min) : 1
|
||||||
@ -326,18 +294,20 @@ Stopped PMS.
|
|||||||
|
|
||||||
Select
|
Select
|
||||||
|
|
||||||
1 - 'stop' PMS
|
1 - 'stop' - Stop PMS
|
||||||
2 - 'automatic' database check, repair/optimize, and reindex in one step.
|
2 - 'automatic' - database check, repair/optimize, and reindex in one step.
|
||||||
3 - 'check' database
|
3 - 'check' - Perform integrity check of database
|
||||||
4 - 'vacuum' database
|
4 - 'vacuum' - Remove empty space from database
|
||||||
5 - 'repair' / 'optimize' database
|
5 - 'repair' - Repair/Optimize databases
|
||||||
6 - 'reindex' database
|
6 - 'reindex' - Rebuild database database indexes
|
||||||
7 - 'start' PMS
|
7 - 'start' - Start PMS
|
||||||
8 - 'import' viewstate (Watch history) from another PMS database
|
|
||||||
9 - 'replace' current database with newest usable backup copy (interactive)
|
8 - 'import' - Import watch history from another database independent of Plex. (risky)
|
||||||
10 - 'show' logfile
|
9 - 'replace' - Replace current databases with newest usable backup copy (interactive)
|
||||||
11 - 'status' of PMS (Stop/Run and databases)
|
10 - 'show' - Show logfile
|
||||||
12 - 'undo' - Undo last successful command
|
11 - 'status' - Report status of PMS (run-state and databases)
|
||||||
|
12 - 'undo' - Undo last successful command
|
||||||
|
|
||||||
99 - exit
|
99 - exit
|
||||||
|
|
||||||
Enter command # -or- command name (4 char min) : auto
|
Enter command # -or- command name (4 char min) : auto
|
||||||
@ -439,76 +409,74 @@ Are you sure (Y/N) ? y
|
|||||||
Deleting all temporary work files.
|
Deleting all temporary work files.
|
||||||
bash-4.4#
|
bash-4.4#
|
||||||
|
|
||||||
======================
|
```
|
||||||
V0.7 = Command line session
|
|
||||||
bash-4.4# ./DBRepair.sh status stop auto status start status exit
|
## Sample (typical) scripted session (e.g. via 'cron')
|
||||||
|
|
||||||
|
```
|
||||||
|
root@lizum:/sata/plex/Plex Media Server/Plug-in Support/Databases# ./DBRepair.sh stop check auto start exit
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Plex Media Server Database Repair Utility (Synology (DSM 7))
|
Plex Media Server Database Repair Utility (Ubuntu 20.04.5 LTS)
|
||||||
Version v1.0.0 - development
|
Version v1.0.0
|
||||||
|
|
||||||
|
|
||||||
[16.40.11]
|
[2023-03-05 18.53.49] Stopping PMS.
|
||||||
[16.40.11] Status report: Sat Feb 25 04:40:11 PM EST 2023
|
[2023-03-05 18.53.49] Stopped PMS.
|
||||||
[16.40.11] PMS is running.
|
|
||||||
[16.40.11] Databases are not checked, Status unknown.
|
|
||||||
[16.40.11]
|
|
||||||
|
|
||||||
[16.40.11] Stopping PMS.
|
[2023-03-05 18.53.49] Checking the PMS databases
|
||||||
[16.40.27] Stopped PMS.
|
[2023-03-05 18.54.22] Check complete. PMS main database is OK.
|
||||||
|
[2023-03-05 18.54.22] Check complete. PMS blobs database is OK.
|
||||||
|
|
||||||
[16.40.27]
|
[2023-03-05 18.54.22] Automatic Check,Repair,Index started.
|
||||||
[16.40.27] Checking the PMS databases
|
[2023-03-05 18.54.22]
|
||||||
[16.42.23] Check complete. PMS main database is OK.
|
[2023-03-05 18.54.22] Checking the PMS databases
|
||||||
[16.42.24] Check complete. PMS blobs database is OK.
|
[2023-03-05 18.54.56] Check complete. PMS main database is OK.
|
||||||
[16.42.24]
|
[2023-03-05 18.54.56] Check complete. PMS blobs database is OK.
|
||||||
[16.42.24] Exporting current databases using timestamp: 2023-02-25_16.40.27
|
[2023-03-05 18.54.56]
|
||||||
[16.42.24] Exporting Main DB
|
[2023-03-05 18.54.56] Exporting current databases using timestamp: 2023-03-05_18.54.22
|
||||||
[16.43.13] Exporting Blobs DB
|
[2023-03-05 18.54.56] Exporting Main DB
|
||||||
[16.43.39] Successfully exported the main and blobs databases. Proceeding to import into new databases.
|
[2023-03-05 18.55.30] Exporting Blobs DB
|
||||||
[16.43.39] Importing Main DB.
|
[2023-03-05 18.55.33] Successfully exported the main and blobs databases. Proceeding to import into new databases.
|
||||||
[16.46.09] Importing Blobs DB.
|
[2023-03-05 18.55.33] Importing Main DB.
|
||||||
[16.46.10] Successfully imported data from SQL files.
|
[2023-03-05 18.57.04] Importing Blobs DB.
|
||||||
[16.46.10] Verifying databases integrity after importing.
|
[2023-03-05 18.57.05] Successfully imported SQL data.
|
||||||
[16.46.58] Verification complete. PMS main database is OK.
|
[2023-03-05 18.57.05] Verifying databases integrity after importing.
|
||||||
[16.46.58] Verification complete. PMS blobs database is OK.
|
[2023-03-05 18.57.40] Verification complete. PMS main database is OK.
|
||||||
[16.46.58] Saving current databases with '-BKUP-2023-02-25_16.40.27'
|
[2023-03-05 18.57.40] Verification complete. PMS blobs database is OK.
|
||||||
[16.46.59] Making imported databases active
|
[2023-03-05 18.57.40] Saving current databases with '-BACKUP-2023-03-05_18.54.22'
|
||||||
[16.46.59] Import complete. Please check your library settings and contents for completeness.
|
[2023-03-05 18.57.40] Making repaired databases active
|
||||||
[16.46.59] Recommend: Scan Files and Refresh all metadata for each library section.
|
[2023-03-05 18.57.40] Repair complete. Please check your library settings and contents for completeness.
|
||||||
[16.46.59]
|
[2023-03-05 18.57.40] Recommend: Scan Files and Refresh all metadata for each library section.
|
||||||
[16.46.59] Backing up of databases
|
[2023-03-05 18.57.40]
|
||||||
[16.46.59] Backup current databases with '-BKUP-2023-02-25_16.46.59' timestamp.
|
[2023-03-05 18.57.40] Backing up of databases
|
||||||
[16.47.03] Reindexing main database
|
[2023-03-05 18.57.40] Backup current databases with '-BACKUP-2023-03-05_18.57.40' timestamp.
|
||||||
[16.47.52] Reindexing main database successful.
|
[2023-03-05 18.57.41] Reindexing main database
|
||||||
[16.47.52] Reindexing blobs database
|
[2023-03-05 18.58.17] Reindexing main database successful.
|
||||||
[16.47.52] Reindexing blobs database successful.
|
[2023-03-05 18.58.17] Reindexing blobs database
|
||||||
[16.47.52] Reindex complete.
|
[2023-03-05 18.58.17] Reindexing blobs database successful.
|
||||||
[16.47.52] Automatic Check,Repair/optimize,Index successful.
|
[2023-03-05 18.58.17] Reindex complete.
|
||||||
|
[2023-03-05 18.58.17] Automatic Check, Repair/optimize, & Index successful.
|
||||||
|
|
||||||
[16.47.52]
|
[2023-03-05 18.58.17] Starting PMS.
|
||||||
[16.47.52] Status report: Sat Feb 25 04:47:52 PM EST 2023
|
[2023-03-05 18.58.17] Started PMS
|
||||||
[16.47.52] PMS is stopped.
|
|
||||||
[16.47.52] Databases are OK.
|
|
||||||
[16.47.52]
|
|
||||||
|
|
||||||
[16.47.52] Starting PMS.
|
|
||||||
[16.48.04] Started PMS
|
|
||||||
|
|
||||||
[16.48.04]
|
|
||||||
[16.48.04] Status report: Sat Feb 25 04:48:04 PM EST 2023
|
|
||||||
[16.48.05] PMS is running.
|
|
||||||
[16.48.05] Databases are OK.
|
|
||||||
[16.48.05]
|
|
||||||
|
|
||||||
bash-4.4#
|
|
||||||
|
|
||||||
|
root@lizum:/sata/plex/Plex Media Server/Plug-in Support/Databases#
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
======================
|
======================
|
||||||
V0.7 = LOGFILE
|
```
|
||||||
|
|
||||||
|
```
|
||||||
|
## Logfile
|
||||||
|
|
||||||
|
The logfile (DBRepair.log) keeps track of all commands issues and their status (PASS/FAIL) with timestamp.
|
||||||
|
This can be useful when recovering from an interrupted session because temporary files are timestamped.
|
||||||
|
|
||||||
|
|
||||||
|
```
|
||||||
2023-02-25 16.14.39 - ============================================================
|
2023-02-25 16.14.39 - ============================================================
|
||||||
2023-02-25 16.14.39 - Session start: Host is Synology (DSM 7)
|
2023-02-25 16.14.39 - Session start: Host is Synology (DSM 7)
|
||||||
2023-02-25 16.14.56 - StopPMS - PASS
|
2023-02-25 16.14.56 - StopPMS - PASS
|
||||||
@ -558,3 +526,90 @@ V0.7 = LOGFILE
|
|||||||
2023-02-25 16.48.04 - StartPMS - PASS
|
2023-02-25 16.48.04 - StartPMS - PASS
|
||||||
2023-02-25 16.48.05 - Exit - Delete temp files.
|
2023-02-25 16.48.05 - Exit - Delete temp files.
|
||||||
2023-02-25 16.48.05 - Session end.
|
2023-02-25 16.48.05 - Session end.
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
# Command Reference:
|
||||||
|
|
||||||
|
### Automatic
|
||||||
|
|
||||||
|
Automatic provides automated processing of most checks and repairs. (Check, Repair/Resequence, Index)
|
||||||
|
In its current state, it will not automatically replace a damaged database from a backup (future)
|
||||||
|
|
||||||
|
It will not stop PMS as not all systems support stopping PMS from within this tool.
|
||||||
|
|
||||||
|
### Check
|
||||||
|
|
||||||
|
Checks the integrity of the Plex main and blobs databases.
|
||||||
|
|
||||||
|
### Exit
|
||||||
|
|
||||||
|
Exits the utility and removes all temporary database files created during processing.
|
||||||
|
To save all intermediate databases, use the 'Quit' command.
|
||||||
|
|
||||||
|
### Import
|
||||||
|
|
||||||
|
Imports (raw) watch history from another PMS database without ability to check validity
|
||||||
|
( This can have side effects of "negative watch count" being displayed. Caution is advised. )
|
||||||
|
|
||||||
|
|
||||||
|
### Reindex
|
||||||
|
|
||||||
|
Rebuilds the database indexes after an import, repair, or replace operation.
|
||||||
|
These indexes are used by PMS for searching (both internally and your typed searches)
|
||||||
|
|
||||||
|
### Repair
|
||||||
|
|
||||||
|
Extracts/recovers all the usable data fron the existing databases into text (SQL ascii) form.
|
||||||
|
Repair then creates new SQLite-valid databases from the extracted/recovered data.
|
||||||
|
|
||||||
|
The side effect of this process is a fully defragmented database (optimal for Plex use).
|
||||||
|
|
||||||
|
100% validity/usability by Plex is not guaranteed as the tool cannot validate each individual
|
||||||
|
record contained in the database. It can only validate at the SQLite level.
|
||||||
|
|
||||||
|
In most cases, Repair is the preferred option as the records extracted are only those SQLite deemed valid.
|
||||||
|
|
||||||
|
### Replace
|
||||||
|
|
||||||
|
Looks through the list of available PMS backups.
|
||||||
|
|
||||||
|
Starting with the most recent PMS backup,
|
||||||
|
1. Check the both db files
|
||||||
|
2. If valid, offer as a replacement choice
|
||||||
|
3. If accepted (Y/N question) then use as the replacement
|
||||||
|
else advance to the next available backup
|
||||||
|
4. Upon completion, validate one final time.
|
||||||
|
|
||||||
|
### Quit
|
||||||
|
|
||||||
|
Exits the utility but leaves the temporary databases intact (useful for making exhaustive backups)
|
||||||
|
|
||||||
|
### Show
|
||||||
|
|
||||||
|
Shows the activity log. The activity log is date/time stamped of all activity.
|
||||||
|
|
||||||
|
### Start
|
||||||
|
|
||||||
|
On platform environments which support it, and when invoked by the 'root' user, the tool can start PMS.
|
||||||
|
If not the 'root' user or on a platform which doesn't support it, "Not available" will be indicated.
|
||||||
|
|
||||||
|
### Stop
|
||||||
|
|
||||||
|
On platform environments which support it, and when invoked by the 'root' user, the tool can stop PMS.
|
||||||
|
If not the 'root' user or on a platform which doesn't support it, "Not available" will be indicated.
|
||||||
|
|
||||||
|
PMS must be in the stopped state in order to operate on the database files.
|
||||||
|
|
||||||
|
### Undo
|
||||||
|
|
||||||
|
Undo allows you to "Undo" the last Import, Repair, Replace, or Vacuum command.
|
||||||
|
At present, it only allows the ONE most recent operation.
|
||||||
|
(Future will support undoing more actions)
|
||||||
|
|
||||||
|
### Vacuum
|
||||||
|
|
||||||
|
Instructs SQLite to remove the empty/deleted records and gaps from the databases.
|
||||||
|
This is most beneficial after deleting whole library sections.
|
||||||
|
|
||||||
|
###
|
||||||
105
ReleaseNotes
Normal file
105
ReleaseNotes
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
|
||||||
|
Release Notes: v0.8.0
|
||||||
|
|
||||||
|
Changes:
|
||||||
|
|
||||||
|
1. "Options" have now become "Commands". You may use either the number or the command name or 4 character
|
||||||
|
abbreviation.
|
||||||
|
|
||||||
|
2. Menu has been resequenced to better reflect typical use sequence.
|
||||||
|
|
||||||
|
3. Commands are not case sensitive.
|
||||||
|
|
||||||
|
4. Commands may be given on the script invocation command line just as "Option number" were.
|
||||||
|
|
||||||
|
5. Some commands accept arguments. These may be entered at the menu command line. If not entered, you will be prompted.
|
||||||
|
|
||||||
|
6. New command "Automatic" (Auto). Automatic performs Check, Repair(or optimize), and Reindex in one step.
|
||||||
|
|
||||||
|
7. PMS can now be stopped/started from within the tool for those environments which support it.
|
||||||
|
If the host/container does not support start/stop then "Not Available" will be shown in the menu
|
||||||
|
|
||||||
|
8. Logfile and console output has been updated to show full date & time.
|
||||||
|
Console output will only show full date & time when running in "Command line" mode (commands on invocation line)
|
||||||
|
|
||||||
|
SAMPLE SESSION
|
||||||
|
|
||||||
|
root@lizum:/sata/plex/Plex Media Server/Plug-in Support/Databases# ./DBRepair.sh stop auto start status exit
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Plex Media Server Database Repair Utility (Ubuntu 20.04.5 LTS)
|
||||||
|
Version v1.0.0 - BETA 2
|
||||||
|
|
||||||
|
|
||||||
|
[2023-03-02 16.28.17] Stopping PMS.
|
||||||
|
[2023-03-02 16.28.19] Stopped PMS.
|
||||||
|
|
||||||
|
[2023-03-02 16.28.19] Automatic Check,Repair,Index started.
|
||||||
|
[2023-03-02 16.28.19]
|
||||||
|
[2023-03-02 16.28.19] Checking the PMS databases
|
||||||
|
[2023-03-02 16.28.21] Check complete. PMS main database is OK.
|
||||||
|
[2023-03-02 16.28.21] Check complete. PMS blobs database is OK.
|
||||||
|
[2023-03-02 16.28.21]
|
||||||
|
[2023-03-02 16.28.21] Exporting current databases using timestamp: 2023-03-02_16.28.19
|
||||||
|
[2023-03-02 16.28.21] Exporting Main DB
|
||||||
|
[2023-03-02 16.28.24] Exporting Blobs DB
|
||||||
|
[2023-03-02 16.28.24] Successfully exported the main and blobs databases. Proceeding to import into new databases.
|
||||||
|
[2023-03-02 16.28.24] Importing Main DB.
|
||||||
|
[2023-03-02 16.28.31] Importing Blobs DB.
|
||||||
|
[2023-03-02 16.28.31] Successfully imported data from SQL files.
|
||||||
|
[2023-03-02 16.28.31] Verifying databases integrity after importing.
|
||||||
|
[2023-03-02 16.28.32] Verification complete. PMS main database is OK.
|
||||||
|
[2023-03-02 16.28.32] Verification complete. PMS blobs database is OK.
|
||||||
|
[2023-03-02 16.28.32] Saving current databases with '-BACKUP-2023-03-02_16.28.19'
|
||||||
|
[2023-03-02 16.28.32] Making imported databases active
|
||||||
|
[2023-03-02 16.28.32] Import complete. Please check your library settings and contents for completeness.
|
||||||
|
[2023-03-02 16.28.32] Recommend: Scan Files and Refresh all metadata for each library section.
|
||||||
|
[2023-03-02 16.28.32]
|
||||||
|
[2023-03-02 16.28.32] Backing up of databases
|
||||||
|
[2023-03-02 16.28.32] Backup current databases with '-BACKUP-2023-03-02_16.28.32' timestamp.
|
||||||
|
[2023-03-02 16.28.33] Reindexing main database
|
||||||
|
[2023-03-02 16.28.34] Reindexing main database successful.
|
||||||
|
[2023-03-02 16.28.34] Reindexing blobs database
|
||||||
|
[2023-03-02 16.28.34] Reindexing blobs database successful.
|
||||||
|
[2023-03-02 16.28.34] Reindex complete.
|
||||||
|
[2023-03-02 16.28.34] Automatic Check,Repair/optimize,Index successful.
|
||||||
|
|
||||||
|
[2023-03-02 16.28.34] Starting PMS.
|
||||||
|
[2023-03-02 16.28.34] Started PMS
|
||||||
|
|
||||||
|
[2023-03-02 16.28.34]
|
||||||
|
[2023-03-02 16.28.34] Status report: Thu 02 Mar 2023 04:28:34 PM EST
|
||||||
|
[2023-03-02 16.28.34] PMS is running.
|
||||||
|
[2023-03-02 16.28.34] Databases are OK.
|
||||||
|
[2023-03-02 16.28.34]
|
||||||
|
|
||||||
|
root@lizum:/sata/plex/Plex Media Server/Plug-in Support/Databases# cat DBRepair.log
|
||||||
|
2023-03-02 16.28.17 - ============================================================
|
||||||
|
2023-03-02 16.28.17 - Session start: Host is Ubuntu 20.04.5 LTS
|
||||||
|
2023-03-02 16.28.19 - Stop - PASS
|
||||||
|
2023-03-02 16.28.19 - Auto - START
|
||||||
|
2023-03-02 16.28.21 - Check - Check com.plexapp.plugins.library.db - PASS
|
||||||
|
2023-03-02 16.28.21 - Check - Check com.plexapp.plugins.library.blobs.db - PASS
|
||||||
|
2023-03-02 16.28.21 - Check - PASS
|
||||||
|
2023-03-02 16.28.24 - Repair - Export databases - PASS
|
||||||
|
2023-03-02 16.28.31 - Repair - Import - PASS
|
||||||
|
2023-03-02 16.28.32 - Repair - Verify main database - PASS (Size: 139MB/139MB).
|
||||||
|
2023-03-02 16.28.32 - Repair - Verify blobs database - PASS (Size: 1MB/1MB).
|
||||||
|
2023-03-02 16.28.32 - Repair - Move files - PASS
|
||||||
|
2023-03-02 16.28.32 - Repair - PASS
|
||||||
|
2023-03-02 16.28.32 - Repair - PASS
|
||||||
|
2023-03-02 16.28.33 - Reindex - MakeBackup com.plexapp.plugins.library.db - PASS
|
||||||
|
2023-03-02 16.28.33 - Reindex - MakeBackup com.plexapp.plugins.library.blobs.db - PASS
|
||||||
|
2023-03-02 16.28.33 - Reindex - MakeBackup - PASS
|
||||||
|
2023-03-02 16.28.34 - Reindex - Reindex: com.plexapp.plugins.library.db - PASS
|
||||||
|
2023-03-02 16.28.34 - Reindex - Reindex: com.plexapp.plugins.library.blobs.db - PASS
|
||||||
|
2023-03-02 16.28.34 - Reindex - PASS
|
||||||
|
2023-03-02 16.28.34 - Reindex - PASS
|
||||||
|
2023-03-02 16.28.34 - Auto - COMPLETED
|
||||||
|
2023-03-02 16.28.34 - Start - PASS
|
||||||
|
2023-03-02 16.28.35 - Exit - Delete temp files.
|
||||||
|
2023-03-02 16.28.35 - Session end. Thu 02 Mar 2023 04:28:35 PM EST
|
||||||
|
2023-03-02 16.28.35 - ============================================================
|
||||||
|
root@lizum:/sata/plex/Plex Media Server/Plug-in Support/Databases#
|
||||||
|
|
||||||
Loading…
x
Reference in New Issue
Block a user