Merge pull request #196 from ChuckPa/chuckpa/may-cleanup

v1.10.05
This commit is contained in:
Chuck 2025-05-20 20:26:59 -04:00 committed by GitHub
commit 21196a3cc3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 44 additions and 4 deletions

View File

@ -2,12 +2,12 @@
#########################################################################
# Plex Media Server database check and repair utility script. #
# Maintainer: ChuckPa #
# Version: v1.10.03 #
# Date: 17-Mar-2025 #
# Version: v1.10.05 #
# Date: 20-May-2025 #
#########################################################################
# Version for display purposes
Version="v1.10.03"
Version="v1.10.05"
# Have the databases passed integrity checks
CheckedDB=0
@ -976,6 +976,9 @@ DoRepair() {
return 1
fi
# Temporary DB actions
"$PLEX_SQLITE" $CPPL.db "DELETE from statistics_bandwidth where account_id is NULL;"
# Continue
Output "Exporting current databases using timestamp: $TimeStamp"
Fail=0
@ -2098,7 +2101,6 @@ do
fi
;;
# Vacuum
4|vacu*)
@ -2268,6 +2270,39 @@ do
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
42|igno*|hono*)

View File

@ -8,6 +8,11 @@
![Maintenance](https://img.shields.io/badge/Maintained-Yes-green.svg)
# 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
1. LC_ALL - When LC_ALL="", set LC_ALL=C (MacOS now needs this)