Fix Storj malformed disk images (script!) for Windows GUI/Docker install

Hi!
A few days ago I restarted Storj from Services and it failed with the error 1067 (unexpected stuff happened, the service failed to start). Checking the logs revealed that one or more of the .db files are malformed. I took it to support, where they lead me to a page explaining how to fix malformed disk images.
Researching a lot to make those linux commands work under Windows I made a little script which goes through all the .db files, with a tutorial to go with it for people like me who has to google everything.

Download the script here: Microsoft OneDrive - Access files anywhere. Create docs with free Office Online.

This will work on any Windows 10 GUI or Docker installation.
Here is a quick step by step guide on how to use it:

  1. Stop Storj.
  2. Unpack “Fix databases.bat” and “sqlitecommands.txt” to any folder on your PC.
  3. Run a disk check to make sure everything is in order on your storage medium. Run “chkdsk z: /f /r /x” where “z” is your Storj drive letter. (You may need to restart your PC for this), make sure Storj is stopped after your PC started back up.
  4. Download Cygwin (needed for linux commands to work under Windows): https ://www.cygwin.com/setup-x86_64.exe
  5. Install Cygwin (select all options) to C:\cygwin
  6. Download sqlite3 (needed to work with databases): https ://sqlite.org/2020/sqlite-tools-win32-x86-3310100.zip
  7. Unpack and copy sqlite3.exe to C:\sqlite3
  8. Add “C:\cygwin” and “C:\sqlite3” to PATH (needed for cmd to know where to look for the commands). If you don’t know how to do this look here: Add to the PATH on Windows 10 | Architect Ryan
  9. a) If Storj stores data in Z:\storage on your computer, proceed to step 10.
    b) If Z:\storage is not where Storj stores your .db files, modify your drive letter to Z: and make sure you have all the .db files in Z:\storage.
    c) If Z:\storage is not where Storj stores your .db files, you can open and modify “Fix databases.bat” and “sqlitecommands.txt” and wherever you see “Z:/storage” modify it to your Storj storage location, where the .db files are. Open them in notepad, press CTRL+H and change EVERY occurance of “Z:/storage” to whatever your location is.
  10. If you only want to repair a few given .db files, feel free to modify “Fix databases.bat” to only have the files you want to repair.
  11. Run “Fix databases.bat” and grab some food, this will take a while.

If you found this helpful drop a thanks to 0xFB2E3e1D409fd44465D6F82cB3A0162ddcd7E6b5 with some Storj tokens if you feel like it :wink:

I think this is a great community and there are several good script here for Windows, mainly in Powershell but also others.

I think StorJ should fix this, as otherwise you will be responsible if anything goes wrongly with your bat file. For example you forget to install cygwin “cp” is not a valid “dos” command in windows so it will fail to copy the files, the good news is that “rm” and “cat” won’t work either, but the sql commands will.
Powershell does however have aliases for all these, so the above is not needed.

Just a heads up when writing scripts, that if you don’t have try/catch mechanisms in place you might destroy the installation