Tachiyomi's Backup Format and JSON

Posted Mar 8, 2024

With the death of Tachiyomi I like so many others decided to look for an alternative. What I found was Mihon, the “successor” to Tachiyomi.

During the migration, I suspected some of my many, many entries (4000+) had disappeared. However, while it quickly became clear that, yes, some entries were missing, it wasn’t obvious which ones had been lost in the migration. So, I wanted to do some digging into my library on Mihon. With that as an excuse to procrastinate harder, I went searching for the structure of the backup format.

It turned out that the application uses something called Protocol Buffers, a format developed by everyone’s favorite private global surveillance corporation, Google. The exported backup file is then finally GZipped and saved with an .tachibk extension. Saving a backup on Mihon’s “preview” build will result in something like app.mihon.debug_2024-01-01_01-00.tachibk.

That’s all manageable so far. However, the Protocol Buffers format isn’t really meant to be humanly readable, or easily parsed for someone like myself with no knowledge of the format whatsoever. So I needed to convert it into something more convenient to work with. I figured that JSON would be a good target for conversion, since it’s fairly easy to quickly glance through and get a feel for what’s going on; and I at least have a clue how to parse it.

A quick search reveled conversion for protobuf to JSON was doable; quite easy in fact. Multiple tools to achieve the task was available. I went with ProtobufJson 1 since I have an intense dislike for JavaScript/TypeScript and whatever else the many other tools were written in.

Now armed with the basic idea of the format and how to convert it, I just needed to run it all through the conversion process. For that to happen, I needed the “backup schema”. Luckily that’s easily fetched from within the application itself by going to Settings -> Advanced -> Debug info -> Backup file schema; then just copy the text and paste it into a new file, e.g. tachiyomi.proto.

Armed with the tools and details we need, the final conversion to JSON is easy:

zcat filename.tachibk | ./ProtobufJson ToJson tachiyomi.proto Backup > output.json

(Using process substitution instead of the pipe < <(zcat filename.tachibk) works too.)


It’s really that simple, once you have a basic idea of what’s going on with the format.

Working with the final JSON file is about as easy as it gets. The format is now humanly readable and easily processed with whatever programming language you’re comfortable with.

Converting back is not much harder. With ProtobufJson, just substitute ToJson with ToProto and change the file inputs and outputs accordingly.

./ProtobufJson ToProto tachiyomi.proto Backup < output.json | gzip -9 > output.tachibk

Notes


  1. I had to modify the code of the ProtobufJson project to get it to build, which you can find right here; and to download a pre-compiled binary if you’re one of those brave types, check out the latest successfull CI pipeline↩︎

Comments