Channel restore


I used CLI to destroy customers account. By my mistake I deleted channel town-square. How I can restore it? Yes… I know, it has been hardcoded. I use MM 5.0

Hi @moon! Here is a command that might help you:

Thanks for help, but I did “./mattermost delete town-square user” instead “./mattermost remove town-square user”. Restore did’nt work. Is any way to put some records into database ?

Hi @moon! What error message are you getting when you try the restore command?

Would this API command help:{channel_id}~1restore%2Fpost?

On chat (in team):
/join town-square
give me: An error occurred while listing channels.

./mattermost channel restore xxx:town-square
give me:
SqlChannelStore.GetByName: Channel does not exist, teamId=poez7bhn3bbkifqy8niitq66fo, name=town-square, sql: no rows in result set
Unable to find channel ‘xxx:town-square’

I have “admin” access account.

@moon Are you able to see the channel in a list when you run the channel list command

i have exactly the same problem. @amy.blais: i can see the channel with mattermost channel list

@hemdknopf The fact that you were able to see the channel using mattermost channel list {teams} I believe means should mean that the channel is still available to be restored back to its original state. Can you please confirm if the mattermost channel restore works for you?

mattermost channel restore {channels}

If not, can you share the error that you are getting from your end?

@moon I suspect that the channel is permanently deleted from Mattermost as explained in the mattermost channel delete section in the documentation.

Permanently delete a channel along with all related information, including posts from the database. Channels can be specified by {team}:{channel} using the team and channel names, or by using channel IDs.

Not sure if you can still recover the channel at this stage. Did you happen to keep a backup of the server prior to the process of deleting the channel?

martin.kraft posted something on a mattermost channel. I’ll try it and give feedback…

@hemdknopf You could try replacing the deleted record with a SQL query. Make sure to replace 1ougsmrabbbi9poh3fqz3nsdje with your old Town Square channel ID and replace 73d1o1a7itfhpxsic7aupqx3hy with your team ID:

INSERT INTO Channels (Id, CreateAt, UpdateAt, DeleteAt, TeamId, Type, DisplayName, Name, Header, Purpose, LastPostAt, TotalMsgCount, ExtraUpdateAt, CreatorId) VALUES ('1ougsmrabbbi9poh3fqz3nsdje', 1549302094226, 1549302094226, 0, '73d1o1a7itfhpxsic7aupqx3hy', 'O', 'Town Square', 'town-square', '', '', 1549302094226, 0, 0, '');


You can get the old Town Square channel ID by querying the Posts table for a post that you know was in Town Square.


SELECT Message, ChannelId FROM Posts;

I would restart Mattermost afterwards.

7:15 PM

(message deleted)

7:15 PM

(message deleted)

Additionally, you may need to do a similar insert into the PublicChannels table.

INSERT INTO PublicChannels (Id, DeleteAt, TeamId, DisplayName, Name, Header, Purpose) VALUES ('1ougsmrabbbi9poh3fqz3nsdje', 0, '73d1o1a7itfhpxsic7aupqx3hy', 'Town Square', 'town-square', '', '');

1 Like