Add License.md, size Reports, README.

This commit is contained in:
ChuckPa 2022-09-21 19:18:17 -04:00
parent 43323e8cbf
commit 00e1080049
No known key found for this signature in database
GPG Key ID: 3CE28A0F6BC31B5B
3 changed files with 95 additions and 9 deletions

41
DBRepair.sh Normal file → Executable file
View File

@ -105,7 +105,7 @@ GetDates(){
Date="$(echo $i | sed -e 's/.*.db-//')" Date="$(echo $i | sed -e 's/.*.db-//')"
# Only add if companion blobs DB exists # Only add if companion blobs DB exists
[ -e "$CPPL.blobs.db-$Date" ] && echo $Date >> "$Tempfile" [ -e $CPPL.blobs.db-$Date ] && echo $Date >> "$Tempfile"
done done
@ -243,6 +243,15 @@ RestoreSaved() {
done done
} }
# Get the size of the given DB in MB
GetSize() {
Size=$(stat -c %s "$1")
Size=$(expr $Size / 1048576)
[ $Size -eq 0 ] && Size=1
echo $Size
}
# Determine which host we are running on and set variables # Determine which host we are running on and set variables
HostConfig() { HostConfig() {
@ -555,11 +564,16 @@ do
# Start vacuuming # Start vacuuming
Output "Vacuuming main database" Output "Vacuuming main database"
SizeStart=$(GetSize $CPPL.db)
# Vacuum it
"$PLEX_SQLITE" $CPPL.db 'VACUUM;' "$PLEX_SQLITE" $CPPL.db 'VACUUM;'
Result=$? Result=$?
if SQLiteOK $Result; then if SQLiteOK $Result; then
Output "Vacuuming main database successful." SizeFinish=$(GetSize $CPPL.db)
WriteLog "Vacuum - Vacuum main database - PASS" Output "Vacuuming main database successful (Size: ${SizeStart}MB/${SizeFinish}MB)."
WriteLog "Vacuum - Vacuum main database - PASS (Size: ${SizeStart}MB/${SizeFinish}MB)."
else else
Output "Vaccuming main database failed. Error code $Result from Plex SQLite" Output "Vaccuming main database failed. Error code $Result from Plex SQLite"
WriteLog "Vacuum - Vacuum main database - FAIL ($Result)" WriteLog "Vacuum - Vacuum main database - FAIL ($Result)"
@ -567,13 +581,18 @@ do
fi fi
Output "Vacuuming blobs database" Output "Vacuuming blobs database"
SizeStart=$(GetSize $CPPL.blobs.db)
# Vacuum it
"$PLEX_SQLITE" $CPPL.blobs.db 'VACUUM;' "$PLEX_SQLITE" $CPPL.blobs.db 'VACUUM;'
Result=$? Result=$?
if SQLiteOK $Result; then if SQLiteOK $Result; then
Output "Vacuuming blobs database successful." SizeFinish=$(GetSize $CPPL.blobs.db)
WriteLog "Vacuum - Vacuum blobs database - PASS" Output "Vacuuming blobs database successful (Size: ${SizeStart}MB/${SizeFinish}MB)."
WriteLog "Vacuum - Vacuum blobs database - PASS (Size: ${SizeStart}MB/${SizeFinish}MB)."
else else
Output "Vaccuming blobs database failed. Error code $Result from Plex SQLite" OutMBput "Vaccuming blobs database failed. Error code $Result from Plex SQLite"
WriteLog "Vacuum - Vacuum blobs database - FAIL ($Result)" WriteLog "Vacuum - Vacuum blobs database - FAIL ($Result)"
Fail=1 Fail=1
fi fi
@ -764,8 +783,10 @@ do
# Check main DB # Check main DB
if CheckDB $CPPL.db-$TimeStamp ; then if CheckDB $CPPL.db-$TimeStamp ; then
SizeStart=$(GetSize $CPPL.db)
SizeFinish=$(GetSize $CPPL.db-$TimeStamp)
Output "Verification complete. PMS main database is OK." Output "Verification complete. PMS main database is OK."
WriteLog "Repair - Verify main database - PASS" WriteLog "Repair - Verify main database - PASS (Size: ${SizeStart}MB/${SizeFinish}MB)."
else else
Output "Verification complete. PMS main database import failed." Output "Verification complete. PMS main database import failed."
WriteLog "Repair - Verify main database - FAIL ($SQLerror)" WriteLog "Repair - Verify main database - FAIL ($SQLerror)"
@ -774,8 +795,10 @@ do
# Check blobs DB # Check blobs DB
if CheckDB $CPPL.blobs.db-$TimeStamp ; then if CheckDB $CPPL.blobs.db-$TimeStamp ; then
SizeStart=$(GetSize $CPPL.blobs.db)
SizeFinish=$(GetSize $CPPL.blobs.db-$TimeStamp)
Output "Verification complete. PMS blobs database is OK." Output "Verification complete. PMS blobs database is OK."
WriteLog "Repair - Verify blobs database - PASS" WriteLog "Repair - Verify blobs database - PASS (Size: ${SizeStart}MB/${SizeFinish}MB)."
else else
Output "Verification complete. PMS blobs database import failed." Output "Verification complete. PMS blobs database import failed."
WriteLog "Repair - Verify main database - FAIL ($SQLerror)" WriteLog "Repair - Verify main database - FAIL ($SQLerror)"
@ -878,7 +901,7 @@ do
for j in "db" "db-wal" "db-shm" "blobs.db" "blobs.db-wal" "blobs.db-shm" for j in "db" "db-wal" "db-shm" "blobs.db" "blobs.db-wal" "blobs.db-shm"
do do
[ -e "$CPPL.$j" ] && mv -f $CPPL.$j "$TMPDIR/$CPPL.$j-ORIG-$TimeStamp" [ -e $CPPL.$j ] && mv -f $CPPL.$j "$TMPDIR/$CPPL.$j-ORIG-$TimeStamp"
done done
WriteLog "Replace - Move Files - PASS" WriteLog "Replace - Move Files - PASS"

7
License.md Normal file
View File

@ -0,0 +1,7 @@
Copyright (c) 2022, ChuckPa.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to use the Software for personal use only. The Software may not be modified, merged, published, distributed, sublicensed, and/or used in other form without the express written consent of the author.
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@ -1 +1,57 @@
# PlexDBRepair # PlexDBRepair
## Introduction
DBRepair provides database repair and maintenance for the most common Plex Media Server database problems.
It is a simple, command line oriented, menu-driven utility.
## Situations and errors commonly seen include:
1. Database is malformed
2. Corruption
3. Damaged indexes
4. Database bloat after optimization
## Functions provided
1. Check the databases
2. Vacuum the databases
3. Reindex the databases
4. Repair damaged databases
5. Restore databases from most recent backup
6. Undo (undo last operation)
7. Show logfile of past actions and status
## Hosts currently supported
1. ASUSTOR
2. Netgear (OS5 Linux-based systems)
3. Linux workstation & server
4. QNAP (QTS & QuTS)
5. Synology (DSM 6 & DSM 7)
## The menu
Plex Media Server Database Repair Utility
Select
1. Check database
2. Vacuum database
3. Reindex database
4. Attempt database repair
5. Replace current database with newest usable backup copy
6. Undo last successful action (Vacuum, Reindex, Repair, or Replace)
7. Show logfile
8. Exit
Enter choice:
## Exiting
When exiting, you will be asked whether to keep the interim temp files created during this session.
If you've encountered any difficulties or aren't sure what to do, don't delete them.
You'll be able to ask in the Plex forums about what to do. Be prepared to present the log file to them.