mirror of
https://github.com/ChuckPa/PlexDBRepair.git
synced 2025-11-19 09:26:07 -05:00
Update Windows scripts to reflect name change
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
@echo off
|
||||
REM PlexDBRepair.bat - Database maintenance / rebuild tool for Windows.
|
||||
REM DBRepair.bat - Database maintenance / rebuild tool for Windows.
|
||||
REM
|
||||
REM This tool currently works as a "full shot" service.
|
||||
REM - everything is done without need to interact.
|
||||
@@ -78,13 +78,13 @@ set "TmpFile=%DBtmp%\results.tmp"
|
||||
|
||||
REM Time now.
|
||||
echo %time% -- ====== Session begins. (%date%) ======
|
||||
echo %time% -- ====== Session begins. (%date%) ====== >> "%PlexData%\PlexDBRepair.log"
|
||||
echo %time% -- ====== Session begins. (%date%) ====== >> "%PlexData%\DBRepair.log"
|
||||
|
||||
REM Make certain Plex is NOT running.
|
||||
tasklist | find /I "Plex Media Server.exe" >NUL
|
||||
if %ERRORLEVEL%==0 (
|
||||
echo %time% -- Plex is running. Please stop Plex Media Server and try again.
|
||||
echo %time% -- Plex is running. Please stop Plex Media Server and try again. >> "%PlexData%\PlexDBRepair.log"
|
||||
echo %time% -- Plex is running. Please stop Plex Media Server and try again. >> "%PlexData%\DBRepair.log"
|
||||
exit /B 1
|
||||
)
|
||||
|
||||
@@ -95,7 +95,7 @@ md "%PlexData%\dbtmp" 2>NUL
|
||||
del "%TmpFile%" 2>NUL
|
||||
|
||||
echo %time% -- Exporting Main DB
|
||||
echo %time% -- Exporting Main DB >> "%PlexData%\PlexDBRepair.log"
|
||||
echo %time% -- Exporting Main DB >> "%PlexData%\DBRepair.log"
|
||||
echo .dump | "%PlexSQL%" "%PlexData%\com.plexapp.plugins.library.db" > "%DBtmp%\library.sql_%TimeStamp%"
|
||||
if not %ERRORLEVEL%==0 (
|
||||
echo %time% -- ERROR: Cannot export Main DB. Aborting.
|
||||
@@ -103,7 +103,7 @@ if not %ERRORLEVEL%==0 (
|
||||
)
|
||||
|
||||
echo %time% -- Exporting Blobs DB
|
||||
echo %time% -- Exporting Blobs DB >> "%PlexData%\PlexDBRepair.log"
|
||||
echo %time% -- Exporting Blobs DB >> "%PlexData%\DBRepair.log"
|
||||
echo .dump | "%PlexSQL%" "%PlexData%\com.plexapp.plugins.library.blobs.db" > "%DBtmp%\blobs.sql_%TimeStamp%"
|
||||
if not %ERRORLEVEL%==0 (
|
||||
echo %time% -- ERROR: Cannot export Blobs DB. Aborting.
|
||||
@@ -111,75 +111,75 @@ if not %ERRORLEVEL%==0 (
|
||||
|
||||
REM Now create new databases from SQL statements
|
||||
echo %time% -- Exporting Complete.
|
||||
echo %time% -- Exporting Complete. >> "%PlexData%\PlexDBRepair.log"
|
||||
echo %time% -- Exporting Complete. >> "%PlexData%\DBRepair.log"
|
||||
|
||||
echo %time% -- Creating Main DB
|
||||
echo %time% -- Creating Main DB >> "%PlexData%\PlexDBRepair.log"
|
||||
echo %time% -- Creating Main DB >> "%PlexData%\DBRepair.log"
|
||||
"%PlexSQL%" "%PlexData%\com.plexapp.plugins.library.db_%TimeStamp%" < "%DBtmp%\library.sql_%TimeStamp%"
|
||||
if not %ERRORLEVEL%==0 (
|
||||
echo %time% -- ERROR: Cannot create Main DB. Aborting.
|
||||
echo %time% -- ERROR: Cannot create Main DB. Aborting. >> "%PlexData%\PlexDBRepair.log"
|
||||
echo %time% -- ERROR: Cannot create Main DB. Aborting. >> "%PlexData%\DBRepair.log"
|
||||
exit /b 3
|
||||
)
|
||||
|
||||
echo %time% -- Verifying Main DB
|
||||
echo %time% -- Verifying Main DB >> "%PlexData%\PlexDBRepair.log"
|
||||
echo %time% -- Verifying Main DB >> "%PlexData%\DBRepair.log"
|
||||
"%PlexSQL%" "%PlexData%\com.plexapp.plugins.library.db_%TimeStamp%" "PRAGMA integrity_check(1)" >"%TmpFile%"
|
||||
set /p Result= < "%TmpFile%"
|
||||
del "%TmpFile%"
|
||||
|
||||
echo %time% -- Main DB verification check is: %Result%
|
||||
echo %time% -- Main DB verification check is: %Result% >> "%PlexData%\PlexDBRepair.log"
|
||||
echo %time% -- Main DB verification check is: %Result% >> "%PlexData%\DBRepair.log"
|
||||
if not "%Result%" == "ok" (
|
||||
echo %time% -- ERROR: Main DB verificaion failed. Exiting.
|
||||
echo %time% -- ERROR: Main DB verificaion failed. Exiting. >> "%PlexData%\PlexDBRepair.log"
|
||||
echo %time% -- ERROR: Main DB verificaion failed. Exiting. >> "%PlexData%\DBRepair.log"
|
||||
exit /B 4
|
||||
)
|
||||
echo %time% -- Main DB verification successful.
|
||||
echo %time% -- Main DB verification successful. >> "%PlexData%\PlexDBRepair.log"
|
||||
echo %time% -- Main DB verification successful. >> "%PlexData%\DBRepair.log"
|
||||
|
||||
|
||||
echo %time% -- Creating Blobs DB
|
||||
echo %time% -- Creating Blobs DB >> "%PlexData%\PlexDBRepair.log"
|
||||
echo %time% -- Creating Blobs DB >> "%PlexData%\DBRepair.log"
|
||||
"%PlexSQL%" "%PlexData%\com.plexapp.plugins.library.blobs.db_%TimeStamp%" < "%DBtmp%\blobs.sql_%TimeStamp%"
|
||||
if not %ERRORLEVEL%==0 (
|
||||
echo %time% -- ERROR: Cannot create Blobs DB. Aborting.
|
||||
echo %time% -- ERROR: Cannot create Blobs DB. Aborting. >> "%PlexData%\PlexDBRepair.log"
|
||||
echo %time% -- ERROR: Cannot create Blobs DB. Aborting. >> "%PlexData%\DBRepair.log"
|
||||
exit /b 5
|
||||
)
|
||||
|
||||
echo %time% -- Verifying Blobs DB
|
||||
echo %time% -- Verifying Blobs DB >> "%PlexData%\PlexDBRepair.log"
|
||||
echo %time% -- Verifying Blobs DB >> "%PlexData%\DBRepair.log"
|
||||
"%PlexSQL%" "%PlexData%\com.plexapp.plugins.library.blobs.db_%TimeStamp%" "PRAGMA integrity_check(1)" > "%TmpFile%"
|
||||
set /p Result= < "%TmpFile%"
|
||||
del "%TmpFile%"
|
||||
|
||||
echo %time% -- Blobs DB verification check is: %Result%
|
||||
echo %time% -- Blobs DB verification check is: %Result% >> "%PlexData%\PlexDBRepair.log"
|
||||
echo %time% -- Blobs DB verification check is: %Result% >> "%PlexData%\DBRepair.log"
|
||||
if not "%Result%" == "ok" (
|
||||
echo %time% -- ERROR: Blobs DB verificaion failed. Exiting.
|
||||
echo %time% -- ERROR: Blobs DB verificaion failed. Exiting. >> "%PlexData%\PlexDBRepair.log"
|
||||
echo %time% -- ERROR: Blobs DB verificaion failed. Exiting. >> "%PlexData%\DBRepair.log"
|
||||
exit /B 6
|
||||
)
|
||||
echo %time% -- Blobs DB verification successful.
|
||||
echo %time% -- Blobs DB verification successful. >> "%PlexData%\PlexDBRepair.log"
|
||||
echo %time% -- Blobs DB verification successful. >> "%PlexData%\DBRepair.log"
|
||||
echo %time% -- Import and verification complete.
|
||||
echo %time% -- Import and verification complete. >> "%PlexData%\PlexDBRepair.log"
|
||||
echo %time% -- Import and verification complete. >> "%PlexData%\DBRepair.log"
|
||||
|
||||
REM Import complete, now reindex
|
||||
echo %time% -- Reindexing Main DB
|
||||
echo %time% -- Reindexing Main DB >> "%PlexData%\PlexDBRepair.log"
|
||||
echo %time% -- Reindexing Main DB >> "%PlexData%\DBRepair.log"
|
||||
"%PlexSQL%" "%PlexData%\com.plexapp.plugins.library.db_%TimeStamp%" "REINDEX;"
|
||||
|
||||
echo %time% -- Reindexing Blobs DB
|
||||
echo %time% -- Reindexing Blobs DB >> "%PlexData%\PlexDBRepair.log"
|
||||
echo %time% -- Reindexing Blobs DB >> "%PlexData%\DBRepair.log"
|
||||
"%PlexSQL%" "%PlexData%\com.plexapp.plugins.library.blobs.db_%TimeStamp%" "REINDEX;"
|
||||
|
||||
REM Index complete, make active
|
||||
echo %time% -- Reindexing complete.
|
||||
echo %time% -- Reindexing complete. >> "%PlexData%\PlexDBRepair.log"
|
||||
echo %time% -- Reindexing complete. >> "%PlexData%\DBRepair.log"
|
||||
echo %time% -- Moving current DBs to DBTMP and making new databases active
|
||||
echo %time% -- Moving current DBs to DBTMP and making new databases active >> "%PlexData%\PlexDBRepair.log"
|
||||
echo %time% -- Moving current DBs to DBTMP and making new databases active >> "%PlexData%\DBRepair.log"
|
||||
|
||||
move "%PlexData%\com.plexapp.plugins.library.db" "%PlexData%\dbtmp\com.plexapp.plugins.library.db_%TimeStamp%"
|
||||
move "%PlexData%\com.plexapp.plugins.library.db_%TimeStamp%" "%PlexData%\com.plexapp.plugins.library.db"
|
||||
@@ -188,9 +188,9 @@ move "%PlexData%\com.plexapp.plugins.library.blobs.db" "%PlexData%\d
|
||||
move "%PlexData%\com.plexapp.plugins.library.blobs.db_%TimeStamp%" "%PlexData%\com.plexapp.plugins.library.blobs.db"
|
||||
|
||||
echo %time% -- Database repair/rebuild/reindex completed.
|
||||
echo %time% -- Database repair/rebuild/reindex completed. >> "%PlexData%\PlexDBRepair.log"
|
||||
echo %time% -- Database repair/rebuild/reindex completed. >> "%PlexData%\DBRepair.log"
|
||||
echo %time% -- ====== Session completed. ======
|
||||
echo %time% -- ====== Session completed. ====== >> "%PlexData%\PlexDBRepair.log"
|
||||
echo %time% -- ====== Session completed. ====== >> "%PlexData%\DBRepair.log"
|
||||
|
||||
exit /b
|
||||
|
||||
@@ -201,5 +201,5 @@ REM Output - Write text to the console and the log file
|
||||
:Output
|
||||
|
||||
echo %time% %~1
|
||||
echo %time% %~1 >> "%PlexData%\PlexDBRepair.log"
|
||||
echo %time% %~1 >> "%PlexData%\DBRepair.log"
|
||||
exit /B
|
||||
|
||||
Reference in New Issue
Block a user