Mattermost, Inc.

[SOLVED] Exporting a Team or Conversation

How do I export an entire conversation… even accessing from the sql database - anyone done this?

Hi @mathurin,

Thanks for your question…

Could you explain a little more about what you’re trying to do and the environment you’re testing in?

Thanks!

Hey Lindy!!! We actually got it working through the database and I’ll add it here in case anyone comes looking for it –

Substitute all query results(ID's) with your own, these are made up

psql --host=127.0.0.1 --dbname=mattermost --username=mmuser --password

###To Pull Posts from Team/Channel

#Grab Team ID
-> select id,name from teams;
b393si6pteamidqufup11i7777

#Grab Channel ID using team id
mattermost=> select id, name, teamid from channels where teamid='b393si6pteamidqufup11i7777';
m88777channelid777ch41r6gw
 
Epoch dates times 

1490760000000
1491019200000

#Grab message between date and time for specified team/channelid
select message from posts where createat BETWEEN 1490760000000 and 1491019200000 and channelid='m88777channelid777ch41r6gw';

#Export to CSV
\copy (select message from posts where createat BETWEEN 1490760000000 and 1491019200000 and channelid='m88777channelid777ch41r6gw') TO 'export_posts.csv' (format CSV);
1 Like

A bit late but MySQL have a nice tool you could use to make this automated:

http://mysqlworkbench.org/2012/11/how-to-migrate-postgresql-databases-to-mysql-using-the-mysql-workbench-migration-wizard/

There are also other alternatives:

@JeffSchering perhaps these are worth mentioning on the docs :stuck_out_tongue:

Great to hear @mathurin!

Thanks for posting your solution @prixone :slight_smile:

I’ll close this off as resolved for now…