Mattermost, Inc.

Mattermost migration from mattermost-docker to a Linux-based operating systems

We are using mattermost-docker for Team Collaboration in our company. Now, we need to switch to a Linux-based operating systems without docker and how can I migrate all data and user from mattermost-docker with postgres database to normal mattermost with mysql database. I’ve tried looking into migration guide but it’s not helping me at all.

Hi @pravin,
if you’re switching Databases your best bet would be the bulk exporter.
See: https://docs.mattermost.com/administration/bulk-export.html

Best regards,
Sven

1 Like

Thank you @sven.huester , will it export everything from team, users and data?

Yes,
it should export every team channel and post as well as all users (inactive, active and bot users) as well as attachment data. Feel free to reach out here again in case you run into any issues.

But I cannot do so on docker container. I’m new to docker and when I run the command it cannot connect to database because database is located in different container with different environment.

What docker image did you use to create the deployment?
And also what command are you running for the export?

I cloned mattermost-docker from https://github.com/mattermost/mattermost-docker
and used docker-compose to set it up. Now, there are 3 containers

  1. mattermost-docker_app
  2. mattermost-docker_db
  3. mattermost-docker_web

so I go to the mattermost-docker_app conatainer and go to /bin and run
./mattermost export bulk file.json --all-teams
no sudo because sudo wasn’t working and I got error connecting to database. Ofcourse there would be error because it is in another container

You need to run the command from the /mattermost directory and it should look like this:

bin/mattermost export bulk bulk-export.jsonl

1 Like

Thank you for your reply @sven.huester.
That would work on normal mattermost setup but I need some docker expertise.
That command won’t work on docker because there’s no mattermost directory. It is managed in container

As you can see from the attached image the command runs just fine on that exact docker install you mentioned. (disregard the 2> /dev/null that is only used to surpress the log messages during the import for this screenshot)

1 Like


I’m getting this error

Hi,
is your Mattermost still running? If you can’t connect to the database then the install shouldn’t work too. Did you change the database connection string?

My mattermost is still running. I haven’t changed anything at all. I just cloned and built image for docker with default configurations.

Then please show the output of docker network list and then docker inspect $(docker network list | grep -i mattermost | cut -f1 -d ' ')

The output for docker network list:

image

The Output for $(docker network list | grep -i mattermost | cut -f1 -d ’ '):

[ { "Name": "mattermost-docker_default", "Id": "af2b59d5cbed180a7dec93e94e0f3faa635b188587fa111dc4ea6b81cb17a7cc", "Created": "2019-11-03T04:49:44.909116597Z", "Scope": "local", "Driver": "bridge", "EnableIPv6": false, "IPAM": { "Driver": "default", "Options": null, "Config": [ { "Subnet": "172.19.0.0/16", "Gateway": "172.19.0.1" } ] }, "Internal": false, "Attachable": true, "Ingress": false, "ConfigFrom": { "Network": "" }, "ConfigOnly": false, "Containers": { "849b741fc050daeec5b491f8c90753768c564cd6619c77ec4ca00b67dd639d2c": { "Name": "mattermost-docker_app_1", "EndpointID": "0187b211cb6f89eb01384e6b0b53e8ccb576e9f885101b39da5b57f062a25d92", "MacAddress": "02:42:ac:13:00:02", "IPv4Address": "172.19.0.2/16", "IPv6Address": "" }, "872fd3993fa293661aab10c6239fe857862d05c0d41bd7f292bfb9326651b3b6": { "Name": "mattermost-docker_db_1", "EndpointID": "a9bb5aef5097ee531b88df0ffdaeb36908fd769b96f546b3fc40428d952693f6", "MacAddress": "02:42:ac:13:00:04", "IPv4Address": "172.19.0.4/16", "IPv6Address": "" }, "c718cce97d842c20815e9a5625db8c5858889c4e48728ddbd87459a4ddfca37b": { "Name": "mattermost-docker_web_1", "EndpointID": "eaba264c82ee6451ffc76c77f6f75d65423f3bd9ec743cc85e05c6bdf4d28bdb", "MacAddress": "02:42:ac:13:00:03", "IPv4Address": "172.19.0.3/16", "IPv6Address": "" } }, "Options": {}, "Labels": { "com.docker.compose.network": "default", "com.docker.compose.project": "mattermost-docker", "com.docker.compose.version": "1.24.1" } } ]

According to the output it can’t work if Mattermost tries to connect to the db on localhost. The containers are in the same docker network but are separated like different computers in an physical network. In the mattermost-docker config Mattermost will connect to db:5432 (DNS is working inside docker netwroks) but your Mattermost tries to connect to 127.0.0.1:5432. Can you please share the redacted connection string from your config.json? If you used the environment variable in the docker-compose.yml then the variable.

This is my docker-compose.yml file
`
app:
build:
context: app
# uncomment following lines for team edition or change UID/GID
# args:
# - edition=team
# - PUID=1000
# - PGID=1000
restart: unless-stopped
volumes:
- ./volumes/app/mattermost/config:/mattermost/config:rw
- ./volumes/app/mattermost/data:/mattermost/data:rw
- ./volumes/app/mattermost/logs:/mattermost/logs:rw
- ./volumes/app/mattermost/plugins:/mattermost/plugins:rw
- ./volumes/app/mattermost/client-plugins:/mattermost/client/plugins:rw
- /etc/localtime:/etc/localtime:ro
environment:
# set same as db credentials and dbname
- MM_USERNAME=*****
- MM_PASSWORD=*****
- MM_DBNAME=*****
# in case your config is not in default location
#- MM_CONFIG=/mattermost/config/config.json

web:
build: web
ports:
- “80:80”
- “443:443”
read_only: true
restart: unless-stopped
volumes:
# This directory must have cert files if you want to enable SSL
- ./volumes/web/cert:/cert:ro
- /etc/localtime:/etc/localtime:ro
# Uncomment for SSL
environment:
- MATTERMOST_ENABLE_SSL=true

`

I don’t know what version you use but as far as i can see the db configuration only lives in the config.json. Can you paste the corresponding redacted line?

“SqlSettings”: {
“DriverName”: “postgres”,
“DataSource”: “user:pass@tcp(localhost:3306)/mattermost_test?charset=utf8mb4,utf8\u0026readTimeout=30s\u0026writeTimeout=30s”,
“DataSourceReplicas”: ,
“DataSourceSearchReplicas”: ,
“MaxIdleConns”: 20,
“ConnMaxLifetimeMilliseconds”: 3600000,
“MaxOpenConns”: 300,
“Trace”: false,
“AtRestEncryptKey”: “somerandomkey”,
“QueryTimeout”: 30
},