Backup from Docker version

Hi, I’ve setup a copy of Mattermost and absolutely loving it. It’s for a community project and I need to make backups of the installation available to other people so if I was to go AWOL they could move to another host.

I can’t for the life of me work out how to access the MySQL database it seems to be using. How can I do that in order to back it up and am I correct in thinking the two things I need to backup are the database and the config.json file?

Thanks,

Ed

Hi beatles1,

We don’t really support our docker image as a production environment. But I can tell you the DB is stored within the docker image. I think the docker export command can help you create backups.

Christopher

1 Like

I didn’t realise about docker not being meant for production, I guess the mattermost-dev suggested name makes sense now! I’ve decided to stick with it because people are already signed up and using it though.

For anyone in the future, as I can’t seem to access MySQL inside the docker container I’ve copied the entire /var/lib/mysql/, /mattermost and /config_docker.json directories and files as I’ve been asked to do application level backups. As you say docker can also export images.

Hi! That topic is old and now Docker is supporter in production!

I wonder what’s the recommanded way to backup a dockerized Mattermost in 2023?

The Backup and recovery doc does not mention anything related to Docker.

This page Backup and restore · Issue #478 · mattermost/mattermost-docker · GitHub is the most recent and pertinent information that I found about backups for Docker… but for the old Docker repository.

Any opinion about the best way to backup a dockerized Mattermost?

Hi daddo,

If you followed the official instructions, all data that needs to be backed up is in the volumes folder, next to your docker compose and the .env files.
Every container (nginx (web), mattermost (app), database (db)) will have its subfolder there. web and app can just be zipped/rsynced directly, no special treatment necessary here. web contains just the webserver configs like certificates or maybe overriden config files. app contains all the config files, your bleve search index (if you use this feature) as well as the logs and the attachments (data subdirectory).
The database running in the default deployment is a PostgreSQL database. If the container is shut down, you can also just rsync it and restore it later at any time - if it’s not, you need to make sure to consistently dump the data and you can follow any PostgreSQL backup tutorial you can find on the internet; the only difference is that you cannot connect to the PostgreSQL port from the outside directly because it’s only exposed inside the docker network, so if you want to use the pg_dump command f.ex., you’d have to exec it in the container context as outlined in the documentation you linked (i.e. docker exec <postgrescontainer> pg_dump ...).

Hope that helps - if I need to be more specific, let me know.

1 Like