mirror of
https://github.com/ChuckPa/PlexDBRepair.git
synced 2025-11-05 18:58:53 -05:00
commit
21196a3cc3
43
DBRepair.sh
43
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.10.03 #
|
# Version: v1.10.05 #
|
||||||
# Date: 17-Mar-2025 #
|
# Date: 20-May-2025 #
|
||||||
#########################################################################
|
#########################################################################
|
||||||
|
|
||||||
# Version for display purposes
|
# Version for display purposes
|
||||||
Version="v1.10.03"
|
Version="v1.10.05"
|
||||||
|
|
||||||
# Have the databases passed integrity checks
|
# Have the databases passed integrity checks
|
||||||
CheckedDB=0
|
CheckedDB=0
|
||||||
@ -976,6 +976,9 @@ DoRepair() {
|
|||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Temporary DB actions
|
||||||
|
"$PLEX_SQLITE" $CPPL.db "DELETE from statistics_bandwidth where account_id is NULL;"
|
||||||
|
|
||||||
# Continue
|
# Continue
|
||||||
Output "Exporting current databases using timestamp: $TimeStamp"
|
Output "Exporting current databases using timestamp: $TimeStamp"
|
||||||
Fail=0
|
Fail=0
|
||||||
@ -2098,7 +2101,6 @@ do
|
|||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
|
||||||
# Vacuum
|
# Vacuum
|
||||||
4|vacu*)
|
4|vacu*)
|
||||||
|
|
||||||
@ -2268,6 +2270,39 @@ do
|
|||||||
WriteLog "Prune - PASS"
|
WriteLog "Prune - PASS"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
|
||||||
|
# Records count
|
||||||
|
30|coun*)
|
||||||
|
|
||||||
|
Temp="$DBDIR/DBRepair.tab1"
|
||||||
|
Temp2="$DBDIR/DBRepair.tab2"
|
||||||
|
|
||||||
|
# Ensure clean
|
||||||
|
rm -f "$Temp" "$Temp2"
|
||||||
|
|
||||||
|
# Get list of tables
|
||||||
|
Tables="$("$PLEX_SQLITE" "$DBDIR/com.plexapp.plugins.library.db" .tables | sed 's/ /\n/g')"
|
||||||
|
|
||||||
|
# Separate and sort tables
|
||||||
|
for i in $Tables
|
||||||
|
do
|
||||||
|
echo $i >> "$Temp"
|
||||||
|
done
|
||||||
|
sort < "$Temp" > "$Temp2"
|
||||||
|
|
||||||
|
Tables="$(cat "$Temp2")"
|
||||||
|
|
||||||
|
# Get counts
|
||||||
|
for Table in $Tables
|
||||||
|
do
|
||||||
|
Records=$("$PLEX_SQLITE" "$DBDIR/com.plexapp.plugins.library.db" "select count(*) from $Table;")
|
||||||
|
printf "%36s %-15d\n" $Table $Records
|
||||||
|
done
|
||||||
|
|
||||||
|
# Cleanup
|
||||||
|
rm -f "$Temp" "$Temp2"
|
||||||
|
;;
|
||||||
|
|
||||||
# Ignore/Honor errors
|
# Ignore/Honor errors
|
||||||
42|igno*|hono*)
|
42|igno*|hono*)
|
||||||
|
|
||||||
|
|||||||
@ -8,6 +8,11 @@
|
|||||||

|

|
||||||
|
|
||||||
# Release Info:
|
# Release Info:
|
||||||
|
v1.10.05
|
||||||
|
|
||||||
|
1. DB Cleanup - Temporary assist with PMS database cleanups
|
||||||
|
2. Record Count report - Report the number of records in each main DB table. (Monitoring growth)
|
||||||
|
|
||||||
v1.10.03
|
v1.10.03
|
||||||
|
|
||||||
1. LC_ALL - When LC_ALL="", set LC_ALL=C (MacOS now needs this)
|
1. LC_ALL - When LC_ALL="", set LC_ALL=C (MacOS now needs this)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user