home
products
contribute
download
documentation
forum
Home
Forums
New posts
Search forums
What's new
New posts
All posts
Latest activity
Members
Registered members
Current visitors
Donate
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Search titles only
By:
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
MediaPortal 1
MediaPortal 1 Plugins
Popular Plugins
My TVSeries
Corrupted database
Contact us
RSS
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="raffe" data-source="post: 1155401" data-attributes="member: 71199"><p>Thanks! Nice script! I added a part that also compresses databases with 7z (free from <a href="http://www.7-zip.org/download.html" target="_blank">http://www.7-zip.org/download.html</a> ) if the integrity is OK and copies the archive and the log to a NAS at the end. Something like this (the "real" differences are in the lines 10-11, 40-43, 49-50, 89-90):</p><p>[CODE=WinBatch]@Echo Off</p><p>::</p><p>:: Auto backup/restore MediaPortal databases based on integrity check.</p><p>::</p><p>:: Author » RoChess</p><p>:: Updated » July 19th 2013</p><p>::</p><p></p><p>:: Make DATETIMEF to something like 2015-10-06_14-18-16 so it can be part of a file name</p><p>SET DATETIMEF=%date%_%time:~0,2%-%time:~3,2%-%time:~6,2%</p><p>SET DATETIMEF=%datetimef: =0%</p><p></p><p>SET BACKUP=AutoBackup</p><p>SET MEPO_PATH=Team MediaPortal\MediaPortal\database</p><p>IF EXIST "%AllUsersProfile%\Application Data\%MEPO_PATH%\*.db3" SET DB3_PATH=%AllUsersProfile%\Application Data\%MEPO_PATH%</p><p>IF EXIST "%AllUsersProfile%\%MEPO_PATH%\*.db3" SET DB3_PATH=%AllUsersProfile%\%MEPO_PATH%</p><p></p><p>IF "%DB3_PATH%"=="" GOTO Error_MePo</p><p>IF NOT EXIST "%~dp0\sqlite3.exe" GOTO Error_SQLite</p><p></p><p>:: Check to make sure MediaPortal is not still running</p><p>::</p><p>tasklist | find /i /c "MediaPortal.exe" >nul &&goto MediaPortalRunning</p><p>tasklist | find /i /c "PluginConfigLoader.exe" >nul &&goto MediaPortalRunning</p><p>tasklist | find /i /c "Moving Pictures Config.exe" >nul &&goto MediaPortalRunning</p><p>tasklist | find /i /c "MP-TVSeries-Configuration.exe" >nul &&goto MediaPortalRunning</p><p></p><p>echo Auto Backup/Restore STARTED (%DATE% -- %TIME%)</p><p>echo Auto Backup/Restore STARTED (%DATE% -- %TIME%) >"%~dpn0.log"</p><p>echo.>>"%~dpn0.log"</p><p></p><p>CD /D "%DB3_PATH%"</p><p>FOR %%I IN (*.db3) DO (</p><p> CALL:checkSQLite "%%I"</p><p>)</p><p></p><p>echo.>>"%~dpn0.log"</p><p>echo Compressed all DB files, copying compressed backup to NAS</p><p>echo Compressed all DB files, copying compressed backup to NAS >>"%~dpn0.log"</p><p>xcopy "%DB3_PATH%\%BACKUP%\MediaPortalAutoBackup%DATETIMEF%*" \\192.168.1.100\Backup\MediaPortal /I /C /D /Y /Q >>"%~dpn0.log"</p><p>echo Copying of MediaPortalAutoBackup%DATETIMEF%.7z is done!</p><p>echo.>>"%~dpn0.log"</p><p>echo Copying of MediaPortalAutoBackup%DATETIMEF%.7z is done! >>"%~dpn0.log"</p><p>echo (-: EVERYTHING IS DONE, HAVE A NICE DAY! :-) >>"%~dpn0.log"</p><p>echo.>>"%~dpn0.log"</p><p>echo Auto Backup/Restore FINISHED (%DATE% -- %TIME%)</p><p>echo Auto Backup/Restore FINISHED (%DATE% -- %TIME%) >>"%~dpn0.log"</p><p> echo *********************************************************************</p><p> echo * Copying backup log to NAS...</p><p>copy "%~dpn0.log" \\192.168.1.100\Backup\MediaPortal\MediaPortalAutoBackup%DATETIMEF%.log /V /Y</p><p> echo *</p><p> echo * (-: EVERYTHING IS DONE, HAVE A NICE DAY! :-)</p><p> echo *</p><p> echo *********************************************************************</p><p> ping 1.1 -n 1 -w 5000 >nul</p><p>cd "%~dp0"</p><p></p><p>:LaunchMediaPortal</p><p> :: Locating MediaPortal folder</p><p> ::</p><p> IF EXIST "%ProgramFiles%\Team MediaPortal\MediaPortal\MediaPortal.exe" (</p><p> start "MediaPortal" "%ProgramFiles%\Team MediaPortal\MediaPortal\MediaPortal.exe"</p><p> ) ELSE (</p><p> IF EXIST "%ProgramFiles(x86)%\Team MediaPortal\MediaPortal\MediaPortal.exe" (</p><p> start "MediaPortal" "%ProgramFiles(x86)%\Team MediaPortal\MediaPortal\MediaPortal.exe"</p><p> ) ELSE (</p><p> Goto MediaPortalNotFound</p><p> )</p><p> )</p><p>GOTO:EOF</p><p></p><p>:checkSQLite</p><p> IF %~z1 EQU 0 (</p><p> echo Aborting: "%~nx1" is ZERO bytes</p><p> echo Aborting: "%~nx1" is ZERO bytes >>"%~dpn0.log"</p><p> GOTO:EOF</p><p> )</p><p> SET Pass=No</p><p> echo *********************************************************************</p><p> echo * Checking Integrity for............: "%~nx1"</p><p> echo PRAGMA integrity_check; | "%~dp0\sqlite3.exe" "%~dpf1" | find /c "ok" > nul &&SET Pass=Yes</p><p> IF "%Pass%"=="Yes" (</p><p> echo * Integrity OK - Updating backup for: "%~nx1"</p><p> echo Integrity OK - Updating backup for: "%~nx1" >>"%~dpn0.log"</p><p> xcopy "%DB3_PATH%\%~nx1" "%DB3_PATH%\%BACKUP%\" /I /C /D /Y /Q >nul</p><p> echo * Compressing this file to archive..: "%~nx1"</p><p> echo Compressing this file to archive..: "%~nx1" >>"%~dpn0.log"</p><p> echo *********************************************************************</p><p> echo Compression progress:</p><p> %~dp0\7z.exe a "%DB3_PATH%\%BACKUP%\MediaPortalAutoBackup%DATETIMEF%" "%DB3_PATH%\%~nx1"</p><p> )</p><p> IF "%Pass%"=="No" (</p><p> echo ERROR: DATABASE CORRUPT!</p><p> IF NOT EXIST "%DB3_PATH%\%BACKUP%\%~nx1" (</p><p> echo - No backup exists for: "%~nx1"</p><p> echo - No backup exists for: "%~nx1" >>"%~dpn0.log"</p><p> )</p><p> IF EXIST "%DB3_PATH%\%BACKUP%\%~nx1" (</p><p> echo - Restoring last-known good backup for: "%~nx1"</p><p> echo - Restoring last-known good backup for: "%~nx1" >>"%~dpn0.log"</p><p> xcopy "%DB3_PATH%\%BACKUP%\%~nx1" "%DB3_PATH%\" /I /C /Y /Q >nul</p><p> )</p><p> )</p><p>GOTO:EOF</p><p></p><p>:MediaPortalRunning</p><p> echo WARNING: MediaPortal is still running!!</p><p> echo.</p><p> echo MediaPortal and/or Configuration tools are still active.</p><p> echo Try it again later, after giving it more time to finish.</p><p>GOTO ErrorDelay</p><p></p><p>:MediaPortalNotFound</p><p> echo WARNING: MediaPortal *NOT* Found!!</p><p> echo.</p><p> echo Unable to locate MediaPortal in the default location.</p><p> echo Please adjust this script manually to use your custom folder.</p><p>goto ErrorDelay</p><p></p><p>:Error_MePo</p><p> echo ABORTING: MediaPortal databases not found</p><p> echo.</p><p> echo Nothing to do, please verify your MediaPortal installation.</p><p>GOTO ErrorDelay</p><p></p><p>:Error_SQLite</p><p> echo ABORTING: SQLite.exe command-line tool missing!</p><p> echo.</p><p> echo Download binary shell for Windows from: http://www.sqlite.org/download.html</p><p> echo Unzip and copy sqlite3.exe to:</p><p> echo.</p><p> echo "%~dp0"</p><p>GOTO ErrorDelay</p><p></p><p>:ErrorDelay</p><p> echo.</p><p> echo *</p><p> echo * This window will self-destruct in a few seconds.</p><p> echo *********************************************************************</p><p> echo.</p><p> ping 1.1 -n 1 -w 5000 >nul</p><p>GOTO:EOF[/CODE]</p></blockquote><p></p>
[QUOTE="raffe, post: 1155401, member: 71199"] Thanks! Nice script! I added a part that also compresses databases with 7z (free from [URL]http://www.7-zip.org/download.html[/URL] ) if the integrity is OK and copies the archive and the log to a NAS at the end. Something like this (the "real" differences are in the lines 10-11, 40-43, 49-50, 89-90): [CODE=WinBatch]@Echo Off :: :: Auto backup/restore MediaPortal databases based on integrity check. :: :: Author » RoChess :: Updated » July 19th 2013 :: :: Make DATETIMEF to something like 2015-10-06_14-18-16 so it can be part of a file name SET DATETIMEF=%date%_%time:~0,2%-%time:~3,2%-%time:~6,2% SET DATETIMEF=%datetimef: =0% SET BACKUP=AutoBackup SET MEPO_PATH=Team MediaPortal\MediaPortal\database IF EXIST "%AllUsersProfile%\Application Data\%MEPO_PATH%\*.db3" SET DB3_PATH=%AllUsersProfile%\Application Data\%MEPO_PATH% IF EXIST "%AllUsersProfile%\%MEPO_PATH%\*.db3" SET DB3_PATH=%AllUsersProfile%\%MEPO_PATH% IF "%DB3_PATH%"=="" GOTO Error_MePo IF NOT EXIST "%~dp0\sqlite3.exe" GOTO Error_SQLite :: Check to make sure MediaPortal is not still running :: tasklist | find /i /c "MediaPortal.exe" >nul &&goto MediaPortalRunning tasklist | find /i /c "PluginConfigLoader.exe" >nul &&goto MediaPortalRunning tasklist | find /i /c "Moving Pictures Config.exe" >nul &&goto MediaPortalRunning tasklist | find /i /c "MP-TVSeries-Configuration.exe" >nul &&goto MediaPortalRunning echo Auto Backup/Restore STARTED (%DATE% -- %TIME%) echo Auto Backup/Restore STARTED (%DATE% -- %TIME%) >"%~dpn0.log" echo.>>"%~dpn0.log" CD /D "%DB3_PATH%" FOR %%I IN (*.db3) DO ( CALL:checkSQLite "%%I" ) echo.>>"%~dpn0.log" echo Compressed all DB files, copying compressed backup to NAS echo Compressed all DB files, copying compressed backup to NAS >>"%~dpn0.log" xcopy "%DB3_PATH%\%BACKUP%\MediaPortalAutoBackup%DATETIMEF%*" \\192.168.1.100\Backup\MediaPortal /I /C /D /Y /Q >>"%~dpn0.log" echo Copying of MediaPortalAutoBackup%DATETIMEF%.7z is done! echo.>>"%~dpn0.log" echo Copying of MediaPortalAutoBackup%DATETIMEF%.7z is done! >>"%~dpn0.log" echo (-: EVERYTHING IS DONE, HAVE A NICE DAY! :-) >>"%~dpn0.log" echo.>>"%~dpn0.log" echo Auto Backup/Restore FINISHED (%DATE% -- %TIME%) echo Auto Backup/Restore FINISHED (%DATE% -- %TIME%) >>"%~dpn0.log" echo ********************************************************************* echo * Copying backup log to NAS... copy "%~dpn0.log" \\192.168.1.100\Backup\MediaPortal\MediaPortalAutoBackup%DATETIMEF%.log /V /Y echo * echo * (-: EVERYTHING IS DONE, HAVE A NICE DAY! :-) echo * echo ********************************************************************* ping 1.1 -n 1 -w 5000 >nul cd "%~dp0" :LaunchMediaPortal :: Locating MediaPortal folder :: IF EXIST "%ProgramFiles%\Team MediaPortal\MediaPortal\MediaPortal.exe" ( start "MediaPortal" "%ProgramFiles%\Team MediaPortal\MediaPortal\MediaPortal.exe" ) ELSE ( IF EXIST "%ProgramFiles(x86)%\Team MediaPortal\MediaPortal\MediaPortal.exe" ( start "MediaPortal" "%ProgramFiles(x86)%\Team MediaPortal\MediaPortal\MediaPortal.exe" ) ELSE ( Goto MediaPortalNotFound ) ) GOTO:EOF :checkSQLite IF %~z1 EQU 0 ( echo Aborting: "%~nx1" is ZERO bytes echo Aborting: "%~nx1" is ZERO bytes >>"%~dpn0.log" GOTO:EOF ) SET Pass=No echo ********************************************************************* echo * Checking Integrity for............: "%~nx1" echo PRAGMA integrity_check; | "%~dp0\sqlite3.exe" "%~dpf1" | find /c "ok" > nul &&SET Pass=Yes IF "%Pass%"=="Yes" ( echo * Integrity OK - Updating backup for: "%~nx1" echo Integrity OK - Updating backup for: "%~nx1" >>"%~dpn0.log" xcopy "%DB3_PATH%\%~nx1" "%DB3_PATH%\%BACKUP%\" /I /C /D /Y /Q >nul echo * Compressing this file to archive..: "%~nx1" echo Compressing this file to archive..: "%~nx1" >>"%~dpn0.log" echo ********************************************************************* echo Compression progress: %~dp0\7z.exe a "%DB3_PATH%\%BACKUP%\MediaPortalAutoBackup%DATETIMEF%" "%DB3_PATH%\%~nx1" ) IF "%Pass%"=="No" ( echo ERROR: DATABASE CORRUPT! IF NOT EXIST "%DB3_PATH%\%BACKUP%\%~nx1" ( echo - No backup exists for: "%~nx1" echo - No backup exists for: "%~nx1" >>"%~dpn0.log" ) IF EXIST "%DB3_PATH%\%BACKUP%\%~nx1" ( echo - Restoring last-known good backup for: "%~nx1" echo - Restoring last-known good backup for: "%~nx1" >>"%~dpn0.log" xcopy "%DB3_PATH%\%BACKUP%\%~nx1" "%DB3_PATH%\" /I /C /Y /Q >nul ) ) GOTO:EOF :MediaPortalRunning echo WARNING: MediaPortal is still running!! echo. echo MediaPortal and/or Configuration tools are still active. echo Try it again later, after giving it more time to finish. GOTO ErrorDelay :MediaPortalNotFound echo WARNING: MediaPortal *NOT* Found!! echo. echo Unable to locate MediaPortal in the default location. echo Please adjust this script manually to use your custom folder. goto ErrorDelay :Error_MePo echo ABORTING: MediaPortal databases not found echo. echo Nothing to do, please verify your MediaPortal installation. GOTO ErrorDelay :Error_SQLite echo ABORTING: SQLite.exe command-line tool missing! echo. echo Download binary shell for Windows from: http://www.sqlite.org/download.html echo Unzip and copy sqlite3.exe to: echo. echo "%~dp0" GOTO ErrorDelay :ErrorDelay echo. echo * echo * This window will self-destruct in a few seconds. echo ********************************************************************* echo. ping 1.1 -n 1 -w 5000 >nul GOTO:EOF[/CODE] [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
MediaPortal 1
MediaPortal 1 Plugins
Popular Plugins
My TVSeries
Corrupted database
Contact us
RSS
Top
Bottom