Data Base File has become corrupted

PhantomBot Version: 3.0.0 (Revision: fcc08b51)
OS Version: Windows 10 10.0 (x86)
Java Version: 1.8.0_211-b12
Browser and Version (for Panel Support): Chrome/Firefox
Stock PhantomBot: Yes

Let us know what help you need: The Phantombot Data Base File somehow became corrupted. When trying to run Phantombot, the drive the bot was on would spike the performance up to 100% (causing games to not be playable). On the browser side, nothing would happen. Would just show a purple loading circle. Switching to using an older Data Base File has fixed the issue.

However, all the data from my community that has been collected for the past 5 months has been lost. There appears to be no way to modify the hours people spent watching the show. For some, they hit major milestones in those times. I need a way to modify those hours. Also to hope this doesn’t happen again.

As with any database/filesystem, corruption can occur. There is not a known way to recover a SQLite3 database that I am aware of. This is why by default every 24 hours a backup is made of the database in the dbbackup directory, and a certain number of days is kept (the default is 5). Did you look through that directory for backups that are automatically generated prior to the corruption?

In the future, you may rely upon those snapshots or configure PhantomBot in botlogin.txt to keep more backups:


Where X is the number of hours that pass between each backup.
Where Y is the number of days to keep backups.

Depending on what part of the database is corrupted it may be possible to recover by dumping and then re-creating the database.

You can try the following steps to attempt a recovery. If this fails, see IO’s post above for the next steps.

  1. Download DB Browser for SQLite
  2. Ensure PhantomBot is completely shutdown
  3. Open the database using DB Browser for SQLite (File > Open or CTRL+O)
  4. Run the integrity check (Tools > Integrity Check). Press OK when prompted about running the query
  5. If the result window (middle window) reports ok under the integrity_check header, then your database should not be corrupt, otherwise, continue to step 6
  6. Attempt to export the database to an SQL file (File > Export > Database to SQL File). Leave all options on the defaults, except for the last drop-down box. Change the last drop-down box to Overwrite old schema, then click Save
  7. If the export fails, see IO’s post above
  8. Create a new database (File > New Database or CTRL+N). Name it phantombot.db, but put it in a separate folder
  9. Cancel out the Edit table definition window that may appear after creating the new db
  10. Import the the database from the SQL file you created in step 6 (File > Import > Database from SQL File). Select No when prompted to create a new database, since you already did that in step 8
  11. Write the changes to the database (Write Changes button on the top bar, File > Write Changes, or CTRL+S)
  12. Delete the corrupt database file, then move the new one you just created into your PhantomBot/config directory
  13. Start the bot and check that everything is working
1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.