mirror of
https://github.com/ChuckPa/PlexDBRepair.git
synced 2025-11-06 03:08:55 -05:00
Minor cleanup from 1.10 release
This commit is contained in:
parent
6aff3e4231
commit
984b4ff861
102
DBRepair.sh
102
DBRepair.sh
@ -2,12 +2,12 @@
|
||||
#########################################################################
|
||||
# Plex Media Server database check and repair utility script. #
|
||||
# Maintainer: ChuckPa #
|
||||
# Version: v1.09.00 #
|
||||
# Date: 06-Nov-2024 #
|
||||
# Version: v1.10.01 #
|
||||
# Date: 02-Jan-2025 #
|
||||
#########################################################################
|
||||
|
||||
# Version for display purposes
|
||||
Version="v1.09.00"
|
||||
Version="v1.10.01"
|
||||
|
||||
# Have the databases passed integrity checks
|
||||
CheckedDB=0
|
||||
@ -1146,7 +1146,7 @@ DoRepair() {
|
||||
fi
|
||||
}
|
||||
|
||||
##### DoReplace
|
||||
##### Replace current DB with a valid backup DB (if available)
|
||||
DoReplace() {
|
||||
|
||||
# If Databases already checked, confirm the user really wants to do this
|
||||
@ -1181,23 +1181,69 @@ DoReplace() {
|
||||
fi
|
||||
|
||||
Output "Database backups available are: $Dates"
|
||||
Output " "
|
||||
Count=0
|
||||
Selection=0
|
||||
Candidate=""
|
||||
Valid=0
|
||||
|
||||
# Print the list of dates
|
||||
for i in $Dates
|
||||
do
|
||||
Count=$((Count + 1))
|
||||
echo " ${Count}) - $i"
|
||||
done
|
||||
|
||||
# Get the selection
|
||||
Selection=""
|
||||
Output " "
|
||||
echo -n "Select backup date by number or date name (blank = return to menu) "
|
||||
read Selection
|
||||
|
||||
# If no selection - return
|
||||
[ "$Selection" = "" ] && return
|
||||
|
||||
# Search for match
|
||||
Candidate=""
|
||||
Count=0
|
||||
for i in $Dates; do
|
||||
Count=$((Count + 1))
|
||||
if [ "$Selection" = "$Count" ] || [ "$Selection" = "$i" ]; then
|
||||
Candidate="$i"
|
||||
fi
|
||||
done
|
||||
|
||||
# If no match, return
|
||||
if [ "$Candidate" = "" ]; then
|
||||
Output "Error. No valid matching main and blobs database pairs. Cannot replace."
|
||||
WriteLog "Replace - Select candidate - FAIL"
|
||||
return
|
||||
fi
|
||||
|
||||
# Check candidate
|
||||
if [ -e $CPPL.db-$i ] && \
|
||||
[ -e $CPPL.blobs.db-$i ] && \
|
||||
Output "Checking database $i" && \
|
||||
CheckDB $CPPL.db-$i && \
|
||||
CheckDB $CPPL.blobs.db-$i ; then
|
||||
if [ -e $CPPL.db-$Candidate ] && \
|
||||
[ -e $CPPL.blobs.db-$Candidate ] ; then
|
||||
|
||||
Output "Found valid database backup date: $i"
|
||||
Candidate=$i
|
||||
Fail=0
|
||||
Output "Checking backup candidate $Candidate"
|
||||
! CheckDB $CPPL.db-$Candidate && Fail=1
|
||||
! CheckDB $CPPL.blobs.db-$Candidate && Fail=1
|
||||
|
||||
[ $Fail -eq 1 ] && Output "Backup from $Candidate is not usable. Try again" && return
|
||||
|
||||
Output "Database backup $Candidate is valid."
|
||||
UseThis=0
|
||||
if ConfirmYesNo "Use backup '$Candidate' ?"; then
|
||||
Output " "
|
||||
|
||||
if ConfirmYesNo "Use backup dated: '$Candidate' ?"; then
|
||||
UseThis=1
|
||||
fi
|
||||
else
|
||||
# Did not pass checks
|
||||
Output "One of the backup files is missing. Please make another selection"
|
||||
Fail=1
|
||||
return
|
||||
fi
|
||||
|
||||
# OK, use this one
|
||||
if [ $UseThis -eq 1 ]; then
|
||||
@ -1212,7 +1258,7 @@ DoReplace() {
|
||||
WriteLog "Replace - Move Files - PASS"
|
||||
|
||||
# Copy this backup into position as primary
|
||||
Output "Copying backup database $Candidate to use as new database."
|
||||
Output "Copying backup database from $Candidate to use as new database."
|
||||
|
||||
cp -p $CPPL.db-$Candidate $CPPL.db-REPLACE-$TimeStamp
|
||||
Result=$?
|
||||
@ -1251,6 +1297,7 @@ DoReplace() {
|
||||
mv $CPPL.blobs.db-REPLACE-$TimeStamp $CPPL.blobs.db
|
||||
|
||||
# done
|
||||
Output " "
|
||||
Output "Database recovery and verification complete."
|
||||
WriteLog "Replace - Verify databases - PASS"
|
||||
|
||||
@ -1278,15 +1325,6 @@ DoReplace() {
|
||||
|
||||
# If successful, save
|
||||
[ $Fail -eq 0 ] && SetLast "Replace" "$TimeStamp"
|
||||
break
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
# Error check if no Candidate found
|
||||
if [ "$Candidate" = "" ]; then
|
||||
Output "Error. No valid matching main and blobs database pairs. Cannot replace."
|
||||
WriteLog "Replace - Select candidate - FAIL"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
@ -1906,8 +1944,7 @@ do
|
||||
echo " 12 - 'undo' - Undo last successful command."
|
||||
|
||||
echo ""
|
||||
echo " 21 - 'prune' - Prune (remove) old image files (jpeg,jpg,png) from PhotoTranscoder cache."
|
||||
echo " 22 - 'purge' - Purge (remove) all temporary files left by PMS & Transcoder in Temp Dir."
|
||||
echo " 21 - 'prune' - Remove old image files (jpeg,jpg,png) from PhotoTranscoder cache & all temp files left by PMS."
|
||||
[ $IgnoreErrors -eq 0 ] && echo " 42 - 'ignore' - Ignore duplicate/constraint errors."
|
||||
[ $IgnoreErrors -eq 1 ] && echo " 42 - 'honor' - Honor all database errors."
|
||||
|
||||
@ -2213,7 +2250,8 @@ do
|
||||
|
||||
|
||||
# Remove (prune) unused image files from PhotoTranscoder Cache > 30 days old.
|
||||
21|prun*|remo*)
|
||||
# Also remove all PMS temp files left behind in TMP. (combine both into one action)
|
||||
21|22|prun*|remo*|purg*)
|
||||
|
||||
# Check if PMS running
|
||||
if IsRunning; then
|
||||
@ -2227,20 +2265,6 @@ do
|
||||
WriteLog "Prune - PASS"
|
||||
;;
|
||||
|
||||
22|purg*)
|
||||
|
||||
# Check if PMS running
|
||||
if IsRunning; then
|
||||
WriteLog "Purge - FAIL - PMS runnning"
|
||||
Output "Unable to purge temp files. PMS is running."
|
||||
continue
|
||||
fi
|
||||
|
||||
WriteLog "Purge - START"
|
||||
DoPurgeTmp
|
||||
WriteLog "Purge - PASS"
|
||||
;;
|
||||
|
||||
# Ignore/Honor errors
|
||||
42|igno*|hono*)
|
||||
|
||||
|
||||
12
ReleaseNotes
12
ReleaseNotes
@ -8,6 +8,18 @@
|
||||

|
||||
|
||||
# Release Info:
|
||||
v1.10.01
|
||||
|
||||
1. Minor cleanup - Cleanup purge/prune handling after merging commands into one.
|
||||
|
||||
v1.10.00
|
||||
|
||||
1. Refactor REPLACE - Processing of DB Replace was awkward.
|
||||
List of available databases will now be printed in a menu
|
||||
After selecting the desired DB, the candidate will be checked.
|
||||
(Selection may be by list item # or date printed)
|
||||
If valid (DB and Blobs) replacement will proceed normally.
|
||||
|
||||
v1.09.00
|
||||
|
||||
1. Purge command - Add 'purge' command to clean up all temporary transcoder and image files.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user