Copy channel chat to another channel

Hello everyone,
Is there a way to copy channel content to another channel? I searched under MMCTL but didn’t find anything.
Cheers Roger

Hi Roger,

do you want do duplicate a given channel with all its content or do you just want to copy some messages to another channel? Can you explain your usecase here so I can think of possible solutions? Thanks!

the situation is as follows: I have a channel with about 100 posts and I want to copy these posts to another channel in the same team, after that I want to delete the old channel.
Many thanks for your effort.

Does the new channel already exist? So let’s say there’s Channel A with 100 messages in it and then there’s Channel B with 200 messages in it and you want to move all posts from Channel A to Channel B so that after this task, Channel B has 300 messages in it and Channel A is empty (with 0 messages) so that it can be deleted afterwards - is that assumption right?
In this case, I would (although it’s not supported) really move the posts in the database directly, since it’s just a simple update statement.

Or does Channel B not exist or is empty at the moment? If this is the case, you could move the channel with all its contents using the mmctl command line utility.

Channel A is already exist with 100 posts and the channel B is the (town-square) channel,of this team,with 200 posts in it after this copy/merge action I want to delete channel A.

Alright, got you.
In this case, I don’t think that there is any supported way to do that.
Please make a backup of your system before reading further here and I need to stress again that this is unsupported and fiddling with the database directly can lead to problems, so this is not an official recommendation here, but I tried it out in one of my test systems and it seems to work without issues.

First of all, you need to connect to your database. I assume you’re using PostgreSQL here, if you’re using MySQL, the commands should still work - let me know if this is not the case.
The source channel in my example is called blah - all posts from there will be moved to the town-square channel.

mattermost=# update posts set channelid=(select id from channels where name='town-square') where channelid=(select id from channels where name='blah');

In this example, 8 posts have been moved to the destination channel and in the connected clients you should almost instantly see them popping up there. The blah channel will still show the old messages, but a ctrl/cmd-shift-r(eload) in the application will fix that and show the channel as empty then.

1 Like

Hi Alexander
Thank you for the unofficial solution .
I spoke to the user and he would be happy if his self-defined channel could be defined as the team default channel. As an example: User joins the team and is directly a member of the “MatterTalk” channel. Is this possible to change the default “Town Square” to “MatterTalk” channel?

You can change the displayname of the “town square” channel to “MatterTalk”, but you cannot change the default channel name. For the time being, a channel named “town-square” is hardcoded in the server and has special roles/properties assigned. So the internal name and link will always be “town-square”, but you can change the name your users see to “MatterTalk”, which should be enough for what you want to achieve here. That being said, if you do not want to copy the posts from the other channel to town-square, you would have to cross-swap the channel name in the database in order to name the new one “town-square”.

Perfekt, the update sql worked perfectly on my test system.
Many thanks for the support.