Mattermost Peer-to-Peer Forum

[solved] How do you restore the mattermost database?


I was looking at the migration documents

In particular, step 4. And step 4 says:
Backup the database from the SOURCE Mattermost server and restore it in place of the database to which the DESTINATION server is connected.

And I’m like, duh. But what are the commands to do it?

I searched around and found the commands to export the database, but trying to restore it, not so lucky. There is this command:
sudo -u mattermost /opt/gitlab/embedded/bin/psql -U gitlab_mattermost -h /var/opt/gitlab/postgresql -d mattermost_production -f ./mattermost_production
But all I get is a bunch of relation exists errors. Is that normal?


I figured it out. I have to remove the old database and create a new one.

sudo -u gitlab-psql /opt/gitlab/embedded/bin/psql -h /var/opt/gitlab/postgresql/ -d gitlabhq_production
drop database mattermost_production
create database mattermost_production

Once that is done, the restore command works with no errors.