DBRepair v1.0.0 development

This commit is contained in:
ChuckPa 2023-02-27 12:57:20 -05:00
parent 6803d3958c
commit 1ef2d87b45
No known key found for this signature in database
GPG Key ID: 3CE28A0F6BC31B5B
3 changed files with 1316 additions and 843 deletions

File diff suppressed because it is too large Load Diff

740
README.md
View File

@ -13,28 +13,71 @@ DBRepair provides database repair and maintenance for the most common Plex Medi
It is a simple menu-driven utility with a command line backend. It is a simple menu-driven utility with a command line backend.
## Situations and errors commonly seen include: ## Situations and errors commonly seen include:
1. Database is malformed 1. Searching is sluggish
2. Corruption 2. Database is malformed / damaged / corrupted
3. Damaged indexes 3. Database has bloated from media addition or changes
4. Database bloat after optimization 4. Damaged indexes damaged
5. Searching gets sluggish
## Functions provided ## Functions provided
1. Check the databases The utility accepts command names.
2. Vacuum the databases Command names may be upper/lower case and may also be abbreviated (4 character minimum).
3. Reindex the databases
4. Repair damaged databases The following commands (or their number), listed in alphabetical order, are accepted as input.
5. Restore databases from most recent backup
6. Import Viewstate / Watch history from another PMS database AUTO(matic) - Automatically check, repair/optimize, and reindex the databases in one step.
7. Undo (undo last operation) CHEC(k) - Check the main and blob databases integrity
8. Show logfile of past actions and status EXIT - Exit the utility
IMPO(rt) - Import viewstate / watch history from another database
REIN(dex) - Rebuild the database indexes
REPL(ace) - Replace the existing databases with a PMS-generated backup
SHOW - Show the log file
STAR(t) - Start PMS (not available on all platforms)
STOP - Stop PMS (not available on all platforms)
UNDO - UNDO the last operation
VACU(um) - Vacuum the databases
### The menu
The menu gives you the option to enter either a 'command number' or the 'command name/abbreviation'.
For clarity, each command's name is 'quoted'.
Plex Media Server Database Repair Utility (_host_configuration_name_)
Version v1.0.0
Select
1 - 'stop' PMS (if available)
2 - 'automatic' database check, repair/optimize, and reindex in one step.
3 - 'check' database
4 - 'vacuum' database
5 - 'repair' / 'optimize' database
6 - 'reindex' database
7 - 'start' PMS (if available)
8 - 'import' viewstate (Watch history) from another PMS database
9 - 'replace' current database with newest usable backup copy (interactive)
10 - 'show' logfile
11 - 'status' of PMS (Stop/Run and databases)
12 - 'undo' - Undo last successful command
99 - exit
Enter command # -or- command name (4 char min) :
## Hosts currently supported ## Hosts currently supported
1. Apple (MacOS) 1. Apple (MacOS)
2. ASUSTOR 2. ASUSTOR
3. Docker (Plex,inc, Linuxserver.io, BinHex & HOTIO via 'docker exec') 3. Docker containers via 'docker exec' command (inside the running container environment)
- Plex,inc.
- Linuxserver.io
- BINHEX
- HOTIO
- Podman (libgpod)
4. Linux workstation & server 4. Linux workstation & server
5. Netgear (OS5 Linux-based systems) 5. Netgear (OS5 Linux-based systems)
6. QNAP (QTS & QuTS) 6. QNAP (QTS & QuTS)
@ -53,6 +96,7 @@ It is a simple menu-driven utility with a command line backend.
ASUSTOR | Public | /volume1/Public ASUSTOR | Public | /volume1/Public
binhex | N/A | Container root (adjacent /config) binhex | N/A | Container root (adjacent /config)
Docker | N/A | Container root (adjacent /config) Docker | N/A | Container root (adjacent /config)
Hotio | N/A | Container root (adjacent /config)
Linux (wkstn/svr) | N/A | Anywhere Linux (wkstn/svr) | N/A | Anywhere
Netgear (ReadyNAS) | "your_choice" | "/data/your_choice" Netgear (ReadyNAS) | "your_choice" | "/data/your_choice"
QNAP (QTS/QuTS) | Public | /share/Public QNAP (QTS/QuTS) | Public | /share/Public
@ -61,43 +105,50 @@ It is a simple menu-driven utility with a command line backend.
Western Digital | Public | /mnt/HD/HD_a2/Public (Does not support 'MyCloudHome' series) Western Digital | Public | /mnt/HD/HD_a2/Public (Does not support 'MyCloudHome' series)
### General installation and usage instructions
``` ```
### To install & launch on general Linux or most Linux NAS platforms: (Showing with v0.6.1)
1. Open your browser to https://github.com/ChuckPa/PlexDBRepair/releases/latest 1. Open your browser to https://github.com/ChuckPa/PlexDBRepair/releases/latest
2. Download the source code (tar.gz) file 2. Download the source code (tar.gz or ZIP) file
3. Place the tar.gz file in the appropriate directory on the system you'll use it.
4. Open a command line session (usually Terminal or SSH) 3. Knowing the file name will always be of the form 'PlexDBRepair-X.Y.Z.tar.gz'
5. Elevate privilege level to root (sudo) -- where X.Y.Z is the release number. Use the real values in place of X, Y, and Z.
6. Extract the utility from the tar or zip file 4. Place the tar.gz file in the appropriate directory on the system you'll use it.
7. 'cd' into the extraction directory 5. Open a command line session (usually Terminal or SSH)
8. Give the utility 'execute' permission 6. Elevate privilege level to root (sudo) if needed.
9. Invoke the utility 7. Extract the utility from the tar or zip file
8. 'cd' into the extraction directory
9. Give DBRepair.sh 'execute' permission (chmod +x)
10. Invoke ./DBRepair.sh
```
### To install & launch on Synology DSM 6 (Showing with v0.6.1) ### EXAMPLE: To install & launch on Synology DSM 6
``` ```
cd /volume1/Plex cd /volume1/Plex
sudo bash sudo bash
tar xf PlexDBRepair-0.6.4.tar.gz tar xf PlexDBRepair-x.y.z.tar.gz
cd PlexDBRepair-0.6.4 cd PlexDBRepair-x.y.z
chmod +x DBRepair.sh chmod +x DBRepair.sh
./DBRepair.sh ./DBRepair.sh
``` ```
### To launch from the commaand line inside a Docker container: ### EXAMPLE: Using DBRepair inside containers (manual start/stop included)
#### (Select containers allow stopping/starting PMS from the menu. See menu for details)
``` ```
sudo docker exec -it plex /bin/bash sudo docker exec -it plex /bin/bash
# Stop Plex when using official Plex,inc image # Stop Plex manually when using official Plex,inc image
/plex_service.sh -d /plex_service.sh -d
--or-- --or--
# Stop Plex when using Linuxserver.io Plex image # Stop Plex manually when using Linuxserver.io Plex image
s6-svc -d /var/run/service/svc-plex s6-svc -d /var/run/service/svc-plex
--or-- --or--
# Stop Plex in binhex containers # Stop Plex manually in binhex containers
kill -15 $(pidof 'Plex Media Server') kill -15 $(pidof 'Plex Media Server')
--or-- --or--
# Stop Plex in HOTIO containers # Stop Plex manually in HOTIO containers
s6-svc -d /run/service/plex s6-svc -d /run/service/plex
@ -107,7 +158,7 @@ It is a simple menu-driven utility with a command line backend.
chmod +x DBRepair.sh chmod +x DBRepair.sh
./DBRepair.sh ./DBRepair.sh
``` ```
### To launch from the command line on Linux ### EXAMPLE: Using DBRepair on regular Linux native host (Workstation/Server)
``` ```
sudo bash sudo bash
systemctl stop plexmediaserver systemctl stop plexmediaserver
@ -118,7 +169,7 @@ It is a simple menu-driven utility with a command line backend.
./DBRepair.sh ./DBRepair.sh
``` ```
### To launch from the command line on MacOS (on the administrator account) ### EXAMPLE: Using DBRepair from the command line on MacOS (on the administrator account)
``` ```
osascript -e 'quit app "Plex Media Server"' osascript -e 'quit app "Plex Media Server"'
cd ~/Downloads cd ~/Downloads
@ -130,63 +181,57 @@ It is a simple menu-driven utility with a command line backend.
``` ```
## 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. Import Viewstate / Watch history from another PMS database
8. Show logfile
9. Exit
Enter choice:
## Typical usage ## Typical usage
``` ```
This utility can only operate on PMS when PMS is in the stopped state. This utility can only operate on PMS when PMS is in the stopped state.
If PMS is running when you startup the utility, it will tell you. If PMS is running when you startup the utility, it will tell you.
A. Database is malformed (Backups of com.plexapp.plugins.library.db and com.plexap.plugins.library.blobs.db available) These examples
1. Check - (Option 1) - Confirm either main or blobs database is damaged
2. Replace - (Option 5) - Use the most recent valid backup -- OR -- Option 4 (Repair). Check date/time for best action.
-- If Replace fails, use Repair (Option 4)
-- Replace can fail if the database has been damaged for a long time.
3. Reindex - (Option 3) - Generate new indexes so PMS doesn't need to at startup
4. Exit - (Option 9)
B. Database is malformed - No Backups A. The most common usage will be the "Automatic" function.
1. Check - (Option 1) - Confirm either main or blobs database is damaged
2. Repair - (Option 4) - Salavage as much as possible from the databases and rebuild them into a usable database. Automatic mode is where DBRepair determines which steps are needed to make your database run optimally.
3. Reindex - (Option 3) - Generate new indexes so PMS doesn't need to at startup For most users, Automatic is equivalent to 'Check, Repair, Reindex'.
4. Exit - (Option 9) This repairs minor damage, vacuums out all the unused records, and rebuilds search indexes in one step.
B. Database is malformed (Backups of com.plexapp.plugins.library.db and com.plexap.plugins.library.blobs.db available)
Note: You may attempt "Repair" sequence
1. (3) Check - Confirm either main or blobs database is damaged
2. (9) Replace - Use the most recent valid backup -- OR -- (5) Repair. Check date/time stamps for best action.
-- If Replace fails, use Repair (5)
-- (Replace can fail if the database has been damaged for a long time.)
3. (6) Reindex - Generate new indexes so PMS doesn't need to at startup
4. (99) Exit
C. Database is malformed - No Backups
1. (3) Check - Confirm either main or blobs database is damaged
2. (5) Repair - Salavage as much as possible from the databases and rebuild them into a usable database.
3. (6) Reindex - Generate new indexes so PMS doesn't need to at startup
4. (99) Exit
C. Database sizes excessively large when compared to amount of media indexed (item count) C. Database sizes excessively large when compared to amount of media indexed (item count)
1. Check - (Option 1) - Make certain both databases are fully intact (repair if needed) 1. (3) Check - Make certain both databases are fully intact (repair if needed)
2. Vacuum - (Option 2) - Instruct SQLite to rebuild its tables and recover unused space. 2. (4) Vacuum - Instruct SQLite to rebuild its tables and recover unused space.
3. Reinex - (Option 3) - Rebuild Indexes. 3. (6) Reindex - Rebuild Indexes.
4. Exit - (Option 9) 4. (99) Exit
D. User interface has become 'sluggish' as more media was added D. User interface has become 'sluggish' as more media was added
1. Check - (Option 1) - Confirm there is no database damage 1. (3) Check - Confirm there is no database damage
2. Repair - (Option 4) - You are not really repairing. You are rebuilding the DB in perfect sorted order. 2. (5) Repair - You are not really repairing. You are rebuilding the DB in perfect sorted order.
3. Reindex - (Option 3) - Rebuild Indexes. 3. (6) Reindex - Rebuild Indexes.
4. Exit - (Option 9) 4. Exit - (Option 9)
E. Undo E. Undo
Undo is a special case where you need the utility to backup ONE step. Undo is a special case where you need the utility to backup ONE step.
This is rarely needed. The only time you might want/need to backup one step is if Replace leaves you worse off This is rarely needed. The only time you might want/need to backup one step is if Replace leaves you worse off
than you were before. In this case, UNDO then Repair. Undo can only undo the single most-recent action. than you were before. In this case, UNDO then Repair. Undo can only undo the single most-recent action.
(Note: In a future release, you will be able to 'undo' every action taken until the DBs are in their original state)
Special considerations: Special considerations:
1. As stated above, this utilty requires PMS to be stopped in order to do what it does. 1. As stated above, this utilty requires PMS to be stopped in order to do what it does.
2. *TRICK* - This utility CAN sit at the menu prompt with PMS running. 2. - This utility CAN sit at the menu prompt with PMS running.
- You did a few things and want to check BEFORE exiting the utility - You did a few things and want to check BEFORE exiting the utility
- If you don't like how it worked out, - If you don't like how it worked out,
-- STOP PMS -- STOP PMS
@ -195,7 +240,7 @@ Special considerations:
3. When satisfied, Exit the utility. 3. When satisfied, Exit the utility.
- There is no harm in keeping the database temp files (except for space used) - There is no harm in keeping the database temp files (except for space used)
- ALL database temps are named with date-time stamps in the name to avoid confusion. - ALL database temps are named with date-time stamps in the name to avoid confusion.
4. The Logfile (Option 8) shows all actions performed WITH the timestamp so you can locate intermediate databases 4. The Logfile ('show' command) shows all actions performed WITH timestamp so you can locate intermediate databases
if desired for special / manual recovery cases. if desired for special / manual recovery cases.
``` ```
@ -210,9 +255,9 @@ Special considerations:
The command line arguments are the same as if typing at the menu. The command line arguments are the same as if typing at the menu.
Example: ./DBRepair.sh 1 4 3 9 Example: ./DBRepair.sh stop auto start exit
This executes: Check, Repair, Reindex, and Exit commands This executes: Stop PMS, Automatic (Check, Repair, Reindex), Start PMS, and Exit commands
## Exiting ## Exiting
@ -247,376 +292,269 @@ bash-4.4# ./DBRepair.sh
=======================================================================================================
bash-4.4# ./DBRepair.sh
Plex Media Server Database Repair Utility (Synology (DSM 7)) Plex Media Server Database Repair Utility (Synology (DSM 7))
Version v1.0.0
Select Select
1. Check database 1 - 'stop' PMS
2. Vacuum database 2 - 'automatic' database check, repair/optimize, and reindex in one step.
3. Reindex database 3 - 'check' database
4. Attempt database repair 4 - 'vacuum' database
5. Replace current database with newest usable backup copy 5 - 'repair' / 'optimize' database
6. Undo last successful action (Vacuum, Reindex, Repair, or Replace) 6 - 'reindex' database
7. Import Viewstate / Watch history from another PMS database 7 - 'start' PMS
8. Show logfile 8 - 'import' viewstate (Watch history) from another PMS database
9. Exit 9 - 'replace' current database with newest usable backup copy (interactive)
10 - 'show' logfile
11 - 'status' of PMS (Stop/Run and databases)
12 - 'undo' - Undo last successful command
99 - exit
Enter command # -or- command name (4 char min) : 1
Stopping PMS.
Stopped PMS.
Select
1 - 'stop' PMS
2 - 'automatic' database check, repair/optimize, and reindex in one step.
3 - 'check' database
4 - 'vacuum' database
5 - 'repair' / 'optimize' database
6 - 'reindex' database
7 - 'start' PMS
8 - 'import' viewstate (Watch history) from another PMS database
9 - 'replace' current database with newest usable backup copy (interactive)
10 - 'show' logfile
11 - 'status' of PMS (Stop/Run and databases)
12 - 'undo' - Undo last successful command
99 - exit
Enter command # -or- command name (4 char min) : auto
Enter choice: 1
Checking the PMS databases Checking the PMS databases
Check complete. PMS main database is OK. Check complete. PMS main database is OK.
Check complete. PMS blobs database is OK. Check complete. PMS blobs database is OK.
Exporting current databases using timestamp: 2023-02-25_16.15.11
Plex Media Server Database Repair Utility (Synology (DSM 7)) Exporting Main DB
Exporting Blobs DB
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. Import Viewstate / Watch history from another PMS database
8. Show logfile
9. Exit
Enter choice: 4
Exporting current databases using timestamp: 2022-11-16_15.56.06
Export: (main)..(blobs)..done.
Successfully exported the main and blobs databases. Proceeding to import into new databases. Successfully exported the main and blobs databases. Proceeding to import into new databases.
Import: (main)..(blobs)..done. Importing Main DB.
Successfully imported data from exported SQL files. Importing Blobs DB.
Successfully imported data from SQL files.
Verifying databases integrity after importing. Verifying databases integrity after importing.
Verification complete. PMS main database is OK. Verification complete. PMS main database is OK.
Verification complete. PMS blobs database is OK. Verification complete. PMS blobs database is OK.
Saving current databases with '-ORIG-2022-11-16_15.56.06' Saving current databases with '-BKUP-2023-02-25_16.15.11'
Making imported databases active Making imported databases active
Import complete. Please check your library settings and contents for completeness. Import complete. Please check your library settings and contents for completeness.
Recommend: Scan Files and Refresh all metadata for each library section. Recommend: Scan Files and Refresh all metadata for each library section.
Plex Media Server Database Repair Utility (Synology (DSM 7))
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. Import Viewstate / Watch history from another PMS database
8. Show logfile
9. Exit
Enter choice: 3
Backing up of databases Backing up of databases
Backup current databases with '-ORIG-2022-11-16_15.56.45' Backup current databases with '-BKUP-2023-02-25_16.20.41' timestamp.
Reindexing main database Reindexing main database
Reindexing main database successful. Reindexing main database successful.
Reindexing blobs database Reindexing blobs database
Reindexing blobs database successful. Reindexing blobs database successful.
Reindex complete. Reindex complete.
Automatic Check,Repair/optimize,Index successful.
Plex Media Server Database Repair Utility (Synology (DSM 7))
Select Select
1. Check database 1 - 'stop' PMS
2. Vacuum database 2 - 'automatic' database check, repair/optimize, and reindex in one step.
3. Reindex database 3 - 'check' database
4. Attempt database repair 4 - 'vacuum' database
5. Replace current database with newest usable backup copy 5 - 'repair' / 'optimize' database
6. Undo last successful action (Vacuum, Reindex, Repair, or Replace) 6 - 'reindex' database
7. Import Viewstate / Watch history from another PMS database 7 - 'start' PMS
8. Show logfile 8 - 'import' viewstate (Watch history) from another PMS database
9. Exit 9 - 'replace' current database with newest usable backup copy (interactive)
10 - 'show' logfile
11 - 'status' of PMS (Stop/Run and databases)
12 - 'undo' - Undo last successful command
99 - exit
Enter choice: 8 Enter command # -or- command name (4 char min) : start
================================================================================== Starting PMS.
2022-11-16 12.32.00 - ============================================================ Started PMS
2022-11-16 12.32.00 - Session start: Host is Synology (DSM 7)
2022-11-16 13.27.03 - ============================================================
2022-11-16 13.27.03 - Session start: Host is Synology (DSM 7)
2022-11-16 13.27.03 - PMS running. Could not continue.
2022-11-16 13.28.16 - ============================================================
2022-11-16 13.28.16 - Session start: Host is Synology (DSM 7)
2022-11-16 13.29.15 - Repair - Export databases - PASS
2022-11-16 13.29.16 - Repair - Import - PASS
2022-11-16 13.29.16 - Repair - Verify main database - PASS (Size: 1MB/1MB).
2022-11-16 13.29.16 - Repair - Verify blobs database - PASS (Size: 1MB/1MB).
2022-11-16 13.29.16 - Repair - Move files - PASS
2022-11-16 13.29.16 - Repair - PASS
2022-11-16 13.32.45 - ============================================================
2022-11-16 13.32.45 - Session start: Host is Synology (DSM 7)
2022-11-16 13.33.26 - PMS running. Could not continue.
2022-11-16 13.36.34 - ============================================================
2022-11-16 13.36.34 - Session start: Host is Synology (DSM 7)
2022-11-16 13.36.34 - PMS running. Could not continue.
2022-11-16 13.36.55 - ============================================================
2022-11-16 13.36.55 - Session start: Host is Synology (DSM 7)
2022-11-16 13.37.10 - PMS running. Could not continue.
2022-11-16 13.41.34 - ============================================================
2022-11-16 13.41.34 - Session start: Host is Synology (DSM 7)
2022-11-16 13.41.34 - PMS running. Could not continue.
2022-11-16 13.41.57 - ============================================================
2022-11-16 13.41.57 - Session start: Host is Synology (DSM 7)
2022-11-16 13.42.06 - Check - Check com.plexapp.plugins.library.db - PASS
2022-11-16 13.42.06 - Check - Check com.plexapp.plugins.library.blobs.db - PASS
2022-11-16 13.42.06 - Check - PASS
2022-11-16 13.42.41 - PMS running. Could not continue.
2022-11-16 13.42.41 - PMS running. Could not continue.
2022-11-16 13.46.36 - PMS running. Could not continue.
2022-11-16 13.47.01 - ============================================================
2022-11-16 13.47.01 - Session start: Host is Synology (DSM 7)
2022-11-16 13.47.32 - PMS running. Could not continue.
2022-11-16 13.47.49 - PMS running. Could not continue.
2022-11-16 13.48.00 - Exit - Delete temp files.
2022-11-16 13.48.00 - Session end.
2022-11-16 13.48.00 - ============================================================
2022-11-16 15.52.09 - PMS running. Could not continue.
2022-11-16 15.55.02 - PMS running. Could not continue.
2022-11-16 15.55.29 - ============================================================
2022-11-16 15.55.29 - Session start: Host is Synology (DSM 7)
2022-11-16 15.55.49 - Check - Check com.plexapp.plugins.library.db - PASS
2022-11-16 15.55.50 - Check - Check com.plexapp.plugins.library.blobs.db - PASS
2022-11-16 15.55.50 - Check - PASS
2022-11-16 15.56.11 - Repair - Export databases - PASS
2022-11-16 15.56.20 - Repair - Import - PASS
2022-11-16 15.56.22 - Repair - Verify main database - PASS (Size: 23MB/22MB).
2022-11-16 15.56.22 - Repair - Verify blobs database - PASS (Size: 1MB/1MB).
2022-11-16 15.56.22 - Repair - Move files - PASS
2022-11-16 15.56.22 - Repair - PASS
2022-11-16 15.56.45 - Reindex - MakeBackup com.plexapp.plugins.library.db - PASS
2022-11-16 15.56.45 - Reindex - MakeBackup com.plexapp.plugins.library.blobs.db - PASS
2022-11-16 15.56.45 - Reindex - MakeBackup - PASS
2022-11-16 15.56.47 - Reindex - Reindex: com.plexapp.plugins.library.db - PASS
2022-11-16 15.56.47 - Reindex - Reindex: com.plexapp.plugins.library.blobs.db - PASS
2022-11-16 15.56.47 - Reindex - PASS
==================================================================================
Plex Media Server Database Repair Utility (Synology (DSM 7))
Select Select
1. Check database 1 - 'stop' PMS
2. Vacuum database 2 - 'automatic' database check, repair/optimize, and reindex in one step.
3. Reindex database 3 - 'check' database
4. Attempt database repair 4 - 'vacuum' database
5. Replace current database with newest usable backup copy 5 - 'repair' / 'optimize' database
6. Undo last successful action (Vacuum, Reindex, Repair, or Replace) 6 - 'reindex' database
7. Import Viewstate / Watch history from another PMS database 7 - 'start' PMS
8. Show logfile 8 - 'import' viewstate (Watch history) from another PMS database
9. Exit 9 - 'replace' current database with newest usable backup copy (interactive)
10 - 'show' logfile
11 - 'status' of PMS (Stop/Run and databases)
12 - 'undo' - Undo last successful command
99 - exit
Enter choice: 7 Enter command # -or- command name (4 char min) : stat
Pathname of database containing watch history to import: /volume1/Plex/backup/com.plexapp.plugins.library.db
Backing up databases
Backup current databases with '-ORIG-2022-11-16_16.02.55'
Exporting Viewstate / Watch history
Making backup copy of main database
Importing Viewstate data
Checking database following import
Viewstate import successful.
Plex Media Server Database Repair Utility (Synology (DSM 7)) Status report: Sat Feb 25 04:38:50 PM EST 2023
PMS is running.
Databases are OK.
Select Select
1. Check database 1 - 'stop' PMS
2. Vacuum database 2 - 'automatic' database check, repair/optimize, and reindex in one step.
3. Reindex database 3 - 'check' database
4. Attempt database repair 4 - 'vacuum' database
5. Replace current database with newest usable backup copy 5 - 'repair' / 'optimize' database
6. Undo last successful action (Vacuum, Reindex, Repair, or Replace) 6 - 'reindex' database
7. Import Viewstate / Watch history from another PMS database 7 - 'start' PMS
8. Show logfile 8 - 'import' viewstate (Watch history) from another PMS database
9. Exit 9 - 'replace' current database with newest usable backup copy (interactive)
10 - 'show' logfile
11 - 'status' of PMS (Stop/Run and databases)
12 - 'undo' - Undo last successful command
99 - exit
Enter choice: 1 Enter command # -or- command name (4 char min) : exit
Checking the PMS databases
Check complete. PMS main database is OK.
Check complete. PMS blobs database is OK.
Plex Media Server Database Repair Utility (Synology (DSM 7))
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. Import Viewstate / Watch history from another PMS database
8. Show logfile
9. Exit
Enter choice: 2
Backing up databases
Backup current databases with '-ORIG-2022-11-16_16.05.37'
Vacuuming main database
Vacuuming main database successful (Size: 22MB/22MB).
Vacuuming blobs database
Vacuuming blobs database successful (Size: 1MB/1MB).
Vacuum complete.
Plex Media Server Database Repair Utility (Synology (DSM 7))
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. Import Viewstate / Watch history from another PMS database
8. Show logfile
9. Exit
Enter choice: 3
Backing up of databases
Backup current databases with '-ORIG-2022-11-16_16.05.44'
Reindexing main database
Reindexing main database successful.
Reindexing blobs database
Reindexing blobs database successful.
Reindex complete.
Plex Media Server Database Repair Utility (Synology (DSM 7))
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. Import Viewstate / Watch history from another PMS database
8. Show logfile
9. Exit
Enter choice: 8
==================================================================================
2022-11-16 12.32.00 - ============================================================
2022-11-16 12.32.00 - Session start: Host is Synology (DSM 7)
2022-11-16 13.27.03 - ============================================================
2022-11-16 13.27.03 - Session start: Host is Synology (DSM 7)
2022-11-16 13.27.03 - PMS running. Could not continue.
2022-11-16 13.28.16 - ============================================================
2022-11-16 13.28.16 - Session start: Host is Synology (DSM 7)
2022-11-16 13.29.15 - Repair - Export databases - PASS
2022-11-16 13.29.16 - Repair - Import - PASS
2022-11-16 13.29.16 - Repair - Verify main database - PASS (Size: 1MB/1MB).
2022-11-16 13.29.16 - Repair - Verify blobs database - PASS (Size: 1MB/1MB).
2022-11-16 13.29.16 - Repair - Move files - PASS
2022-11-16 13.29.16 - Repair - PASS
2022-11-16 13.32.45 - ============================================================
2022-11-16 13.32.45 - Session start: Host is Synology (DSM 7)
2022-11-16 13.33.26 - PMS running. Could not continue.
2022-11-16 13.36.34 - ============================================================
2022-11-16 13.36.34 - Session start: Host is Synology (DSM 7)
2022-11-16 13.36.34 - PMS running. Could not continue.
2022-11-16 13.36.55 - ============================================================
2022-11-16 13.36.55 - Session start: Host is Synology (DSM 7)
2022-11-16 13.37.10 - PMS running. Could not continue.
2022-11-16 13.41.34 - ============================================================
2022-11-16 13.41.34 - Session start: Host is Synology (DSM 7)
2022-11-16 13.41.34 - PMS running. Could not continue.
2022-11-16 13.41.57 - ============================================================
2022-11-16 13.41.57 - Session start: Host is Synology (DSM 7)
2022-11-16 13.42.06 - Check - Check com.plexapp.plugins.library.db - PASS
2022-11-16 13.42.06 - Check - Check com.plexapp.plugins.library.blobs.db - PASS
2022-11-16 13.42.06 - Check - PASS
2022-11-16 13.42.41 - PMS running. Could not continue.
2022-11-16 13.42.41 - PMS running. Could not continue.
2022-11-16 13.46.36 - PMS running. Could not continue.
2022-11-16 13.47.01 - ============================================================
2022-11-16 13.47.01 - Session start: Host is Synology (DSM 7)
2022-11-16 13.47.32 - PMS running. Could not continue.
2022-11-16 13.47.49 - PMS running. Could not continue.
2022-11-16 13.48.00 - Exit - Delete temp files.
2022-11-16 13.48.00 - Session end.
2022-11-16 13.48.00 - ============================================================
2022-11-16 15.52.09 - PMS running. Could not continue.
2022-11-16 15.55.02 - PMS running. Could not continue.
2022-11-16 15.55.29 - ============================================================
2022-11-16 15.55.29 - Session start: Host is Synology (DSM 7)
2022-11-16 15.55.49 - Check - Check com.plexapp.plugins.library.db - PASS
2022-11-16 15.55.50 - Check - Check com.plexapp.plugins.library.blobs.db - PASS
2022-11-16 15.55.50 - Check - PASS
2022-11-16 15.56.11 - Repair - Export databases - PASS
2022-11-16 15.56.20 - Repair - Import - PASS
2022-11-16 15.56.22 - Repair - Verify main database - PASS (Size: 23MB/22MB).
2022-11-16 15.56.22 - Repair - Verify blobs database - PASS (Size: 1MB/1MB).
2022-11-16 15.56.22 - Repair - Move files - PASS
2022-11-16 15.56.22 - Repair - PASS
2022-11-16 15.56.45 - Reindex - MakeBackup com.plexapp.plugins.library.db - PASS
2022-11-16 15.56.45 - Reindex - MakeBackup com.plexapp.plugins.library.blobs.db - PASS
2022-11-16 15.56.45 - Reindex - MakeBackup - PASS
2022-11-16 15.56.47 - Reindex - Reindex: com.plexapp.plugins.library.db - PASS
2022-11-16 15.56.47 - Reindex - Reindex: com.plexapp.plugins.library.blobs.db - PASS
2022-11-16 15.56.47 - Reindex - PASS
2022-11-16 16.03.16 - Import - Attempting to import watch history from '/volume1/Plex/backup/com.plexapp.plugins.library.db'
2022-11-16 16.04.56 - Import - MakeBackup com.plexapp.plugins.library.db - PASS
2022-11-16 16.04.56 - Import - MakeBackup com.plexapp.plugins.library.blobs.db - PASS
2022-11-16 16.04.56 - Import - MakeBackups - PASS
2022-11-16 16.04.59 - Import - Import: /volume1/Plex/backup/com.plexapp.plugins.library.db - PASS
2022-11-16 16.05.34 - Check - Check com.plexapp.plugins.library.db - PASS
2022-11-16 16.05.34 - Check - Check com.plexapp.plugins.library.blobs.db - PASS
2022-11-16 16.05.34 - Check - PASS
2022-11-16 16.05.37 - Vacuum - MakeBackup com.plexapp.plugins.library.db - PASS
2022-11-16 16.05.38 - Vacuum - MakeBackup com.plexapp.plugins.library.blobs.db - PASS
2022-11-16 16.05.38 - Vacuum - MakeBackups - PASS
2022-11-16 16.05.40 - Vacuum - Vacuum main database - PASS (Size: 22MB/22MB).
2022-11-16 16.05.41 - Vacuum - Vacuum blobs database - PASS (Size: 1MB/1MB).
2022-11-16 16.05.41 - Vacuum - PASS
2022-11-16 16.05.44 - Reindex - MakeBackup com.plexapp.plugins.library.db - PASS
2022-11-16 16.05.44 - Reindex - MakeBackup com.plexapp.plugins.library.blobs.db - PASS
2022-11-16 16.05.44 - Reindex - MakeBackup - PASS
2022-11-16 16.05.46 - Reindex - Reindex: com.plexapp.plugins.library.db - PASS
2022-11-16 16.05.46 - Reindex - Reindex: com.plexapp.plugins.library.blobs.db - PASS
2022-11-16 16.05.46 - Reindex - PASS
==================================================================================
Plex Media Server Database Repair Utility (Synology (DSM 7))
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. Import Viewstate / Watch history from another PMS database
8. Show logfile
9. Exit
Enter choice: 9
Ok to remove temporary databases/workfiles for this session? (Y/N) ? y Ok to remove temporary databases/workfiles for this session? (Y/N) ? y
Are you sure (Y/N) ? y Are you sure (Y/N) ? y
Deleting all temporary work files. Deleting all temporary work files.
bash-4.4# bash-4.4#
```
======================
V0.7 = Command line session
bash-4.4# ./DBRepair.sh status stop auto status start status exit
Plex Media Server Database Repair Utility (Synology (DSM 7))
Version v1.0.0 - development
[16.40.11]
[16.40.11] Status report: Sat Feb 25 04:40:11 PM EST 2023
[16.40.11] PMS is running.
[16.40.11] Databases are not checked, Status unknown.
[16.40.11]
[16.40.11] Stopping PMS.
[16.40.27] Stopped PMS.
[16.40.27]
[16.40.27] Checking the PMS databases
[16.42.23] Check complete. PMS main database is OK.
[16.42.24] Check complete. PMS blobs database is OK.
[16.42.24]
[16.42.24] Exporting current databases using timestamp: 2023-02-25_16.40.27
[16.42.24] Exporting Main DB
[16.43.13] Exporting Blobs DB
[16.43.39] Successfully exported the main and blobs databases. Proceeding to import into new databases.
[16.43.39] Importing Main DB.
[16.46.09] Importing Blobs DB.
[16.46.10] Successfully imported data from SQL files.
[16.46.10] Verifying databases integrity after importing.
[16.46.58] Verification complete. PMS main database is OK.
[16.46.58] Verification complete. PMS blobs database is OK.
[16.46.58] Saving current databases with '-BKUP-2023-02-25_16.40.27'
[16.46.59] Making imported databases active
[16.46.59] Import complete. Please check your library settings and contents for completeness.
[16.46.59] Recommend: Scan Files and Refresh all metadata for each library section.
[16.46.59]
[16.46.59] Backing up of databases
[16.46.59] Backup current databases with '-BKUP-2023-02-25_16.46.59' timestamp.
[16.47.03] Reindexing main database
[16.47.52] Reindexing main database successful.
[16.47.52] Reindexing blobs database
[16.47.52] Reindexing blobs database successful.
[16.47.52] Reindex complete.
[16.47.52] Automatic Check,Repair/optimize,Index successful.
[16.47.52]
[16.47.52] Status report: Sat Feb 25 04:47:52 PM EST 2023
[16.47.52] PMS is stopped.
[16.47.52] Databases are OK.
[16.47.52]
[16.47.52] Starting PMS.
[16.48.04] Started PMS
[16.48.04]
[16.48.04] Status report: Sat Feb 25 04:48:04 PM EST 2023
[16.48.05] PMS is running.
[16.48.05] Databases are OK.
[16.48.05]
bash-4.4#
======================
V0.7 = LOGFILE
2023-02-25 16.14.39 - ============================================================
2023-02-25 16.14.39 - Session start: Host is Synology (DSM 7)
2023-02-25 16.14.56 - StopPMS - PASS
2023-02-25 16.16.06 - Check - Check com.plexapp.plugins.library.db - PASS
2023-02-25 16.16.06 - Check - Check com.plexapp.plugins.library.blobs.db - PASS
2023-02-25 16.16.06 - Check - PASS
2023-02-25 16.17.20 - Repair - Export databases - PASS
2023-02-25 16.19.52 - Repair - Import - PASS
2023-02-25 16.20.41 - Repair - Verify main database - PASS (Size: 399MB/399MB).
2023-02-25 16.20.41 - Repair - Verify blobs database - PASS (Size: 1MB/1MB).
2023-02-25 16.20.41 - Repair - Move files - PASS
2023-02-25 16.20.41 - Repair - PASS
2023-02-25 16.20.41 - Repair - PASS
2023-02-25 16.20.46 - Reindex - MakeBackup com.plexapp.plugins.library.db - PASS
2023-02-25 16.20.46 - Reindex - MakeBackup com.plexapp.plugins.library.blobs.db - PASS
2023-02-25 16.20.46 - Reindex - MakeBackup - PASS
2023-02-25 16.21.34 - Reindex - Reindex: com.plexapp.plugins.library.db - PASS
2023-02-25 16.21.35 - Reindex - Reindex: com.plexapp.plugins.library.blobs.db - PASS
2023-02-25 16.21.35 - Reindex - PASS
2023-02-25 16.21.35 - Reindex - PASS
2023-02-25 16.21.35 - Auto - PASS
2023-02-25 16.38.35 - StartPMS - PASS
2023-02-25 16.38.57 - Exit - Delete temp files.
2023-02-25 16.38.58 - Session end.
2023-02-25 16.38.58 - ============================================================
2023-02-25 16.40.10 - ============================================================
2023-02-25 16.40.10 - Session start: Host is Synology (DSM 7)
2023-02-25 16.40.27 - StopPMS - PASS
2023-02-25 16.42.23 - Check - Check com.plexapp.plugins.library.db - PASS
2023-02-25 16.42.24 - Check - Check com.plexapp.plugins.library.blobs.db - PASS
2023-02-25 16.42.24 - Check - PASS
2023-02-25 16.43.39 - Repair - Export databases - PASS
2023-02-25 16.46.10 - Repair - Import - PASS
2023-02-25 16.46.58 - Repair - Verify main database - PASS (Size: 399MB/399MB).
2023-02-25 16.46.58 - Repair - Verify blobs database - PASS (Size: 1MB/1MB).
2023-02-25 16.46.59 - Repair - Move files - PASS
2023-02-25 16.46.59 - Repair - PASS
2023-02-25 16.46.59 - Repair - PASS
2023-02-25 16.47.03 - Reindex - MakeBackup com.plexapp.plugins.library.db - PASS
2023-02-25 16.47.03 - Reindex - MakeBackup com.plexapp.plugins.library.blobs.db - PASS
2023-02-25 16.47.03 - Reindex - MakeBackup - PASS
2023-02-25 16.47.52 - Reindex - Reindex: com.plexapp.plugins.library.db - PASS
2023-02-25 16.47.52 - Reindex - Reindex: com.plexapp.plugins.library.blobs.db - PASS
2023-02-25 16.47.52 - Reindex - PASS
2023-02-25 16.47.52 - Reindex - PASS
2023-02-25 16.47.52 - Auto - PASS
2023-02-25 16.48.04 - StartPMS - PASS
2023-02-25 16.48.05 - Exit - Delete temp files.
2023-02-25 16.48.05 - Session end.