Hello, @hereIam
Just sharing some alternatives here. May I know if you would be interested to use a plugin to achieve this process from the UI?
The plugin that I refer to is the Mattermost Channel Export Plugin. Something that you would like to check on, maybe.