Backup a Single Channel?

Hi there,

My organization is planning on wiping Mattermost messages after n months, but we have a Contracts channel that we would like to keep backed up indefinitely. Does anyone have a suggestion on how to organize something like that? Will I need to manually export from the DB every n months?

Thank you very much and I appreciate the help.

Hi Michael,
Maybe you could write a bot for that.

It would get all posts since the previous backup with Get Posts.
You get a list with all the posts, you can read each post with Get Post If there are files included you can get them with Get File.

Your bot can store it in the way you want.
Kind regards,
Tom

1 Like

Thank you Tom, I appreciate your response. I will look into this and report back!

You could store all the posts in an single large HTM-file with some css. It could even look like the Mattermost channel and it is easy to store, copy and restore/search.

Hi, everyone.

I created this forum topic for your reference - How to Export a Single Channel from Mattermost Server Hope it helps!

I would suggest writing some sort of a script, such as a bash file for Linux operating systems, that would automatically query the database and utilize the DROP command in combination with IF and regex strings, to allow you to match and automatically update the range of time that you want to delete messages in. You could also implement the NOT function into the query, for the channel ID of the channel you wish to preserve all messages in. If you were to schedule the script to be executed with a cron job then it is very possible that this could be a solution. You could additionally extend the functionality of the script by adding additional clauses to back up the specific channel(s) you wish to save to a SQL file, and commit them to a private GitHub repository or AWS S3 bucket prior to the deletion of other messages, etc.