mirror of
https://github.com/ChuckPa/PlexDBRepair.git
synced 2025-11-06 03:08:55 -05:00
Merge pull request #22 from ChuckPa/chuckpa/improve-restore-logic
Improve database backup selection logic, Add BINHEX support
This commit is contained in:
commit
6b253b26fd
35
DBRepair.sh
35
DBRepair.sh
@ -396,8 +396,8 @@ HostConfig() {
|
|||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
# Docker
|
# Docker (All main docker variants except binhex)
|
||||||
elif [ -f /bin/s6-svscan ] && [ -d "/config/Library/Application Support" ]; then
|
elif [ "$(grep docker /proc/1/cgroup | wc -l)" -gt 0 ] && [ -d "/config/Library/Application Support" ]; then
|
||||||
|
|
||||||
PLEX_SQLITE="/usr/lib/plexmediaserver/Plex SQLite"
|
PLEX_SQLITE="/usr/lib/plexmediaserver/Plex SQLite"
|
||||||
AppSuppDir="/config/Library/Application Support"
|
AppSuppDir="/config/Library/Application Support"
|
||||||
@ -409,6 +409,19 @@ HostConfig() {
|
|||||||
HostType="Docker"
|
HostType="Docker"
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
# BINHEX Plex container
|
||||||
|
elif [ "$(grep docker /proc/1/cgroup | wc -l)" -gt 0 ] && [ -d "/config/Plex Media Server" ]; then
|
||||||
|
|
||||||
|
PLEX_SQLITE="/usr/lib/plexmediaserver/Plex SQLite"
|
||||||
|
AppSuppDir="/config"
|
||||||
|
PID_FILE="$AppSuppDir/Plex Media Server/plexmediaserver.pid"
|
||||||
|
DBDIR="$AppSuppDir/Plex Media Server/Plug-in Support/Databases"
|
||||||
|
LOGFILE="$DBDIR/DBRepair.log"
|
||||||
|
LOG_TOOL="logger"
|
||||||
|
|
||||||
|
HostType="BINHEX"
|
||||||
|
return 0
|
||||||
|
|
||||||
# Western Digital (OS5)
|
# Western Digital (OS5)
|
||||||
elif [ -f /etc/system.conf ] && [ -d /mnt/HD/HD_a2/Nas_Prog/plexmediaserver ] && \
|
elif [ -f /etc/system.conf ] && [ -d /mnt/HD/HD_a2/Nas_Prog/plexmediaserver ] && \
|
||||||
grep "Western Digital Corp" /etc/system.conf >/dev/null; then
|
grep "Western Digital Corp" /etc/system.conf >/dev/null; then
|
||||||
@ -959,14 +972,16 @@ do
|
|||||||
Output "Checking for a usable backup."
|
Output "Checking for a usable backup."
|
||||||
Candidate=""
|
Candidate=""
|
||||||
|
|
||||||
|
Output "Database backups available are: $Dates"
|
||||||
for i in $Dates
|
for i in $Dates
|
||||||
do
|
do
|
||||||
|
|
||||||
# Check candidate
|
# Check candidate
|
||||||
if [ -e $CPPL.db-$i ] && \
|
if [ -e $CPPL.db-$i ] && \
|
||||||
[ -e $CPPL.blobs.db-$i ] && \
|
[ -e $CPPL.blobs.db-$i ] && \
|
||||||
CheckDB $CPPL.db-$i && \
|
Output "Checking database $i" && \
|
||||||
CheckDB $CPPL.blobs.db-$i ; then
|
CheckDB $CPPL.db-$i && \
|
||||||
|
CheckDB $CPPL.blobs.db-$i ; then
|
||||||
|
|
||||||
Output "Found valid database backup date: $i"
|
Output "Found valid database backup date: $i"
|
||||||
Candidate=$i
|
Candidate=$i
|
||||||
@ -1052,11 +1067,11 @@ do
|
|||||||
WriteLog "Replace - Verify databases - FAIL"
|
WriteLog "Replace - Verify databases - FAIL"
|
||||||
Fail=1
|
Fail=1
|
||||||
fi
|
fi
|
||||||
fi
|
|
||||||
|
|
||||||
# If successful, save
|
# If successful, save
|
||||||
[ $Fail -eq 0 ] && SetLast "Replace" "$TimeStamp"
|
[ $Fail -eq 0 ] && SetLast "Replace" "$TimeStamp"
|
||||||
break
|
break
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|||||||
45
README.md
45
README.md
@ -49,15 +49,18 @@ It is a simple menu-driven utility with a command line backend.
|
|||||||
```
|
```
|
||||||
Vendor | Shared folder name | directory
|
Vendor | Shared folder name | directory
|
||||||
-------------------+---------------------+------------------------------------------
|
-------------------+---------------------+------------------------------------------
|
||||||
|
Apple | Downloads | ~/Downloads
|
||||||
ASUSTOR | Public | /volume1/Public
|
ASUSTOR | Public | /volume1/Public
|
||||||
Netgear (ReadyNAS) | "your_choice" | "/data/your_choice"
|
binhex | N/A | Container root (adjacent /config)
|
||||||
Synology (DSM 6) | Plex | /volume1/Plex (change volume as required)
|
|
||||||
Synology (DSM 7) | PlexMediaServer | /volume1/PlexMediaServer (change volume as required)
|
|
||||||
QNAP (QTS/QuTS) | Public | /share/Public
|
|
||||||
Western Digital | Public | /mnt/HD/HD_a2/Public (Does not support 'MyCloudHome' series)
|
|
||||||
Docker | N/A | Container root (adjacent /config)
|
Docker | N/A | Container root (adjacent /config)
|
||||||
Linux (wkstn/svr) | N/A | Anywhere
|
Linux (wkstn/svr) | N/A | Anywhere
|
||||||
Apple | Downloads | ~/Downloads
|
Netgear (ReadyNAS) | "your_choice" | "/data/your_choice"
|
||||||
|
QNAP (QTS/QuTS) | Public | /share/Public
|
||||||
|
Synology (DSM 6) | Plex | /volume1/Plex (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)
|
||||||
|
|
||||||
|
|
||||||
```
|
```
|
||||||
### To install & launch on general Linux or most Linux NAS platforms:
|
### To install & launch on general Linux or most Linux NAS platforms:
|
||||||
1. Place the tar/zip/sh file in the appropriate directory
|
1. Place the tar/zip/sh file in the appropriate directory
|
||||||
@ -70,7 +73,7 @@ It is a simple menu-driven utility with a command line backend.
|
|||||||
```
|
```
|
||||||
cd /volume1/Plex
|
cd /volume1/Plex
|
||||||
sudo bash
|
sudo bash
|
||||||
tar xf DBRepair.tar
|
tar xf DBRepair.tar.gz
|
||||||
chmod +x DBRepair.sh
|
chmod +x DBRepair.sh
|
||||||
./DBRepair.sh
|
./DBRepair.sh
|
||||||
```
|
```
|
||||||
@ -84,9 +87,13 @@ It is a simple menu-driven utility with a command line backend.
|
|||||||
--or--
|
--or--
|
||||||
# Stop Plex when using Linuxserver.io Plex image
|
# Stop Plex when using Linuxserver.io Plex image
|
||||||
s6-svc -d /var/run/service/svc-plex
|
s6-svc -d /var/run/service/svc-plex
|
||||||
|
--or--
|
||||||
|
# Stop Plex in binhex containers
|
||||||
|
kill -15 $(pidof 'Plex Media Server')
|
||||||
|
|
||||||
|
|
||||||
tar xf DBRepair.tar
|
|
||||||
|
tar xf DBRepair.tar.gz
|
||||||
chmod +x DBRepair.sh
|
chmod +x DBRepair.sh
|
||||||
./DBRepair.sh
|
./DBRepair.sh
|
||||||
```
|
```
|
||||||
@ -95,7 +102,7 @@ It is a simple menu-driven utility with a command line backend.
|
|||||||
sudo bash
|
sudo bash
|
||||||
systemctl stop plexmediaserver
|
systemctl stop plexmediaserver
|
||||||
cd /path/to/DBRepair.tar
|
cd /path/to/DBRepair.tar
|
||||||
tar xf DBRepair.tar
|
tar xf DBRepair.tar.gz
|
||||||
./DBRepair.sh
|
./DBRepair.sh
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -179,6 +186,22 @@ Special considerations:
|
|||||||
if desired for special / manual recovery cases.
|
if desired for special / manual recovery cases.
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Scripting support
|
||||||
|
|
||||||
|
Certain platforms don't provide for each command line access.
|
||||||
|
To support those products, this utility can be operated by adding command line arguments.
|
||||||
|
|
||||||
|
Another use of this feature is to automate Plex Database maintenance
|
||||||
|
( Stop Plex, Run this sequence, Start Plex ) at a time when the server isn't busy
|
||||||
|
|
||||||
|
|
||||||
|
The command line arguments are the same as if typing at the menu.
|
||||||
|
|
||||||
|
Example: ./DBRepair.sh 1 4 3 9
|
||||||
|
|
||||||
|
This executes: Check, Repair, Reindex, and Exit commands
|
||||||
|
|
||||||
|
|
||||||
## Exiting
|
## Exiting
|
||||||
|
|
||||||
When exiting, you will be asked whether to keep the interim temp files created during this session.
|
When exiting, you will be asked whether to keep the interim temp files created during this session.
|
||||||
@ -188,7 +211,9 @@ Special considerations:
|
|||||||
|
|
||||||
## Sample session
|
## Sample session
|
||||||
|
|
||||||
This sample session shows:
|
|
||||||
|
|
||||||
|
This sample session shows all the features present. You won't use :
|
||||||
1. PMS exclusive access to the databases interlock protecting your data
|
1. PMS exclusive access to the databases interlock protecting your data
|
||||||
2. Basic checks, vacuum, and reindex
|
2. Basic checks, vacuum, and reindex
|
||||||
3. Full export/import (repair) which also reloads the database in perfect order
|
3. Full export/import (repair) which also reloads the database in perfect order
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user