1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Corrupted database

Discussion in 'My TVSeries' started by de2maso, July 11, 2013.

  1. de2maso

    de2maso Portal Member

    Joined:
    March 10, 2010
    Messages:
    33
    Likes Received:
    5
    Ratings:
    +5 / 0
    Home Country:
    Norway Norway
    Show System Specs
    Hi

    I need some help.

    After Windows gave me a BSOD last night i'm having trouble getting Mediaportal to boot up.
    I was at the time adding a new episode to My Tvseries folder.

    So I have disabled Tv-series in the config, and now MP will start again.

    My question is, do i uninstall, and reinstall?, do I delete some database files? or do I use Windows system restore a couple of days back.



    Need logs: tell me :)

    Whats the best approach ?

    Thanks
     
  2. Google AdSense Guest Advertisement



    to hide all adverts.
  3. ltfearme
    • Premium Supporter

    ltfearme Community Plugin Dev

    Joined:
    June 10, 2007
    Messages:
    6,335
    Likes Received:
    4,116
    Gender:
    Male
    Occupation:
    Software Test Engineer
    Location:
    Sydney
    Ratings:
    +5,205 / 0
    Home Country:
    Australia Australia
    Just delete your database or restore from backup.
     
  4. kiwijunglist
    • Team MediaPortal

    kiwijunglist Super Moderator

    Joined:
    June 10, 2008
    Messages:
    6,720
    Likes Received:
    1,412
    Occupation:
    Doctor
    Location:
    New Zealand
    Ratings:
    +1,836 / 9
    Home Country:
    New Zealand New Zealand
    Show System Specs
  5. mattjcurry
    • Team MediaPortal

    mattjcurry Development Group

    Joined:
    October 24, 2011
    Messages:
    261
    Likes Received:
    195
    Ratings:
    +226 / 0
    Can you post logs? If MySQL is corrupt, it should show up in the logs.
     
  6. kiwijunglist
    • Team MediaPortal

    kiwijunglist Super Moderator

    Joined:
    June 10, 2008
    Messages:
    6,720
    Likes Received:
    1,412
    Occupation:
    Doctor
    Location:
    New Zealand
    Ratings:
    +1,836 / 9
    Home Country:
    New Zealand New Zealand
    Show System Specs

    So when I had this problem MP wouldn't start, it took me 1 hour to figure out it was a corrupted database in tv series plugin. Is there a quick check that could be done by tv series on startup that would show up more than half of the database corruption problems, and if database is corrupt then tv series skips what ever start up process that causes MP to hang, and then when you try to enter tv series it gives a window saying corrupt database?
     
    Last edited: July 12, 2013
  7. RoChess
    • Premium Supporter

    RoChess Extension Developer

    Joined:
    March 10, 2006
    Messages:
    3,993
    Likes Received:
    1,256
    Ratings:
    +1,585 / 2
    I actually have a small script at home that does a quick SQLite database integrity check on all DB3 databases, and if valid it auto-backs it up (which then makes it the most recent 'good' backup), and when it fails auto-restores the last good-backup.

    Will rewrite the script to become generic for everybody, and not just specific to my own needs. The benefit is that it works on all databases then, and not just MP-TVSeries. The backup MPEI plugin might also be of use, because it also takes care of the thumbs folder if memory serves me.

    Not gonna have time this weekend, but will get to it next weekend, or before.
     
    • Like Like x 2
  8. de2maso

    de2maso Portal Member

    Joined:
    March 10, 2010
    Messages:
    33
    Likes Received:
    5
    Ratings:
    +5 / 0
    Home Country:
    Norway Norway
    Show System Specs
    Thanks for input guys

    @ RoChess that script sounds interesting to try out ! :)
     
  9. RoChess
    • Premium Supporter

    RoChess Extension Developer

    Joined:
    March 10, 2006
    Messages:
    3,993
    Likes Received:
    1,256
    Ratings:
    +1,585 / 2
    Finally found some time to scrub script, so here goes:

    Show Spoiler

    Code (Winbatch):
    1. @Echo Off
    2. ::
    3. :: Auto backup/restore MediaPortal databases based on integrity check.
    4. ::
    5. :: Author  » RoChess
    6. :: Updated » July 19th 2013
    7. ::
    8. SET BACKUP=AutoBackup
    9. SET MEPO_PATH=Team MediaPortal\MediaPortal\database
    10. IF EXIST "%AllUsersProfile%\Application Data\%MEPO_PATH%\*.db3" SET DB3_PATH=%AllUsersProfile%\Application Data\%MEPO_PATH%
    11. IF EXIST "%AllUsersProfile%\%MEPO_PATH%\*.db3"   SET DB3_PATH=%AllUsersProfile%\%MEPO_PATH%
    12. IF "%DB3_PATH%"=="" GOTO Error_MePo
    13. IF NOT EXIST "%~dp0\sqlite3.exe" GOTO Error_SQLite
    14. :: Check to make sure MediaPortal is not still running
    15. ::
    16. tasklist | find /i /c "MediaPortal.exe" >nul &&goto MediaPortalRunning
    17. tasklist | find /i /c "PluginConfigLoader.exe" >nul &&goto MediaPortalRunning
    18. tasklist | find /i /c "Moving Pictures Config.exe" >nul &&goto MediaPortalRunning
    19. tasklist | find /i /c "MP-TVSeries-Configuration.exe" >nul &&goto MediaPortalRunning
    20.  
    21. echo Auto Backup/Restore STARTED (%DATE% -- %TIME%) >"%~dpn0.log"
    22. echo.>>"%~dpn0.log"
    23. CD /D "%DB3_PATH%"
    24. FOR %%I IN (*.db3) DO (
    25. CALL:checkSQLite "%%I"
    26. )
    27. echo.>>"%~dpn0.log"
    28. echo Auto Backup/Restore FINISHED (%DATE% -- %TIME%) >>"%~dpn0.log"
    29. :LaunchMediaPortal
    30. :: Locating MediaPortal folder
    31. ::
    32. IF EXIST "%ProgramFiles%\Team MediaPortal\MediaPortal\MediaPortal.exe"  (
    33.   start "MediaPortal" "%ProgramFiles%\Team MediaPortal\MediaPortal\MediaPortal.exe"
    34. ) ELSE (
    35.   IF EXIST "%ProgramFiles(x86)%\Team MediaPortal\MediaPortal\MediaPortal.exe"  (
    36.    start "MediaPortal" "%ProgramFiles(x86)%\Team MediaPortal\MediaPortal\MediaPortal.exe"
    37.   ) ELSE (
    38.    Goto MediaPortalNotFound
    39.   )
    40. )
    41. GOTO:EOF
    42. :checkSQLite
    43. IF %~z1 EQU 0 (
    44.   echo    Aborting: "%~nx1" is ZERO bytes
    45.   echo    Aborting: "%~nx1" is ZERO bytes >>"%~dpn0.log"
    46.   GOTO:EOF
    47. )
    48. SET Pass=No
    49. echo PRAGMA integrity_check; | "%~dp0\sqlite3.exe" "%~dpf1" | find /c "ok" > nul &&SET Pass=Yes
    50. IF "%Pass%"=="Yes" (
    51.   echo    Updating backup for: "%~nx1"
    52.   echo    Updating backup for: "%~nx1" >>"%~dpn0.log"
    53.   xcopy "%DB3_PATH%\%~nx1" "%DB3_PATH%\%BACKUP%\" /I /C /D /Y /Q >nul
    54. )
    55. IF "%Pass%"=="No" (
    56.   echo    ERROR: DATABASE CORRUPT!
    57.   IF NOT EXIST "%DB3_PATH%\%BACKUP%\%~nx1" (
    58.    echo     - No backup exists for: "%~nx1"
    59.    echo     - No backup exists for: "%~nx1" >>"%~dpn0.log"
    60.   )
    61.   IF EXIST "%DB3_PATH%\%BACKUP%\%~nx1" (
    62.    echo     - Restoring last-known good backup for: "%~nx1"
    63.    echo     - Restoring last-known good backup for: "%~nx1" >>"%~dpn0.log"
    64.    xcopy "%DB3_PATH%\%BACKUP%\%~nx1" "%DB3_PATH%\" /I /C /Y /Q >nul
    65.   )
    66. )
    67. GOTO:EOF
    68. :MediaPortalRunning
    69. echo   WARNING: MediaPortal is still running!!
    70. echo.
    71. echo     MediaPortal and/or Configuration tools are still active.
    72. echo     Try it again later, after giving it more time to finish.
    73. GOTO ErrorDelay
    74. :MediaPortalNotFound
    75. echo   WARNING: MediaPortal *NOT* Found!!
    76. echo.
    77. echo     Unable to locate MediaPortal in the default location.
    78. echo     Please adjust this script manually to use your custom folder.
    79. goto ErrorDelay
    80. :Error_MePo
    81. echo   ABORTING: MediaPortal databases not found
    82. echo.
    83. echo     Nothing to do, please verify your MediaPortal installation.
    84. GOTO ErrorDelay
    85. :Error_SQLite
    86. echo   ABORTING: SQLite.exe command-line tool missing!
    87. echo.
    88. echo     Download binary shell for Windows from: [URL]http://www.sqlite.org/download.html[/URL]
    89. echo     Unzip and copy sqlite3.exe to:
    90. echo.
    91. echo         "%~dp0"
    92. GOTO ErrorDelay
    93. :ErrorDelay
    94. echo.
    95. echo   This window will self-destruct in a few seconds.
    96. echo.
    97. ping 1.1 -n 1 -w 5000 >nul
    98. GOTO:EOF
    99.  


    To make it easier, I've attached script+sqlite3.exe in a ZIP file.

    Function:

    - It will use sqlite3.exe tool to verify all the DB3 databases did not go corrupt.
    - If DB3 passes check, it will make a fresh backup.
    - If check fails, it will auto-recover last-known good backup.
    - After it backed-up/restored all the databases, it will launch MediaPortal (it also does a check to make sure MePo is not running)

    Use this script to replace the method in which you normally launch MediaPortal.
     

    Attached Files:

    • Thank You! Thank You! x 4
    • Like Like x 1
  10. de2maso

    de2maso Portal Member

    Joined:
    March 10, 2010
    Messages:
    33
    Likes Received:
    5
    Ratings:
    +5 / 0
    Home Country:
    Norway Norway
    Show System Specs
    @RoChess: Sorry for a late reply, been away on holiday.

    This looks amazing just tried it out, and seems to work well, i got a autobackup log file. Thank you so much!!

    Just to verify I understand everything correctly : Do you actually use the Atuobackup.cmd to start MP everytime ?

    See i got some keymapping going on my keyboard, so I need todo some remapping if that is the case.

    Again : great work! :)
     
  11. RoChess
    • Premium Supporter

    RoChess Extension Developer

    Joined:
    March 10, 2006
    Messages:
    3,993
    Likes Received:
    1,256
    Ratings:
    +1,585 / 2
    I use a slightly modified version that also checks if RDP is active, and I have that script in my 'startup' folder so when the computer boots, it launches MediaPortal (and does the auto-backup/restore), but then on my ATi Remote Wonder, the 'A' button at the top next to the Power-Off button to shut down MediaPortal allows me to re-activate it. Then inside Windows I changed the CMD display to be "Lucida console" font size 20, white background with black text. That way it doesn't look horrible for me as I like a 'bright' environment.

    The existing script verifies if any MediaPortal related item (the ones I'm aware off) is already running and prevents it from running again. So if I accidently click the 'A button while MePo is already running, the CMD window will show ontop and auto-dissapears after a while with the error message to not start it again.

    Sometimes MediaPortal takes longer then usually to 'stop' as well when I close it, so the same method prevents dbase corruption from occuring then, and the script will fix it if it does happen.
     
Loading...

Users Viewing Thread (Users: 0, Guests: 0)

  • About The Project

    The vision of the MediaPortal project is to create a free open source media centre application, which supports all advanced media centre functions, and is accessible to all Windows users.

    In reaching this goal we are working every day to make sure our software is one of the best.

             

  • Like Us On Facebook

  • Support MediaPortal!

    The team works very hard to make sure the community is running the best HTPC-software. We give away MediaPortal for free but hosting and software is not for us.

    Care to support our work with a few bucks? We'd really appreciate it!