Export long iPhone message conversation via command line to PDF or HTML?
This is not a complete answer but this blog post[1] is a possible lead. Apparently this guy found out where some of the files are located. I have yet to try his solution. I will post back here after I've tried it.

[1] https://linuxsleuthing.blogspot.com/2015/01/getting-attached-apple-messaging.html