Mattermost, Inc.

Export Mattermost from another location

Here’s the situation: We had a power outage. Our server got hosed. The backup team attempted to restore but it is still hosed. But, they can restore the data on the server but put it in another location (e.g. /RESTORE).
I understand how to do a normal export of the data, but that involves everything operating as normal. But this is not normal conditions.
I tried running the command to export the data:
sudo -H -u mattermost bash -c '/RESTORE/opt/gitlab/embedded/bin/pg_dump -U gitlab_mattermost -h /RESTORE/var/opt/gitlab/postgresql -p 5432 mattermost_production > /tmp/mattermost_production.sql'
But it says it requires server running and accepting connections.

So how do I export this data at this other location? I’m sure there’s some command to get this /RESTORE database started so the export can take place, but I don’t know what it is.

Hi @edomingox, wondering if this doc might help: https://docs.mattermost.com/administration/backup.html.

I looked into that before and I don’t think it works for the situation I’m in. That looks like it works during normal operations. So on the same server, I already have mattermost running, but it is pretty much empty (from scratch), and I have a backup copy of all the files from the same server placed in another directory. From there, I want to be able to export THAT particular instance of mattermost and restore it on the mattermost current up and running. I just don’t know how to access the database because normally, gitlab-ctl controls that.

If I just copy over a certain directory, will that work?

So I figured out how to do it myself. The solution involves two servers.

  1. On the backup server, ensure there is a running instance of gitlab. This instance will get trashed.

  2. On the backup server, delete the directory /var/opt/gitlab/postgresql
    This action will corrupt gitlab. This is why it must be done on a backup server.

  3. Copy the “restored” data to the backup gitlab server.
    example: cp -ar /RESTORE/var/opt/gitlab/postgresql /var/opt/gitlab

  4. Change ownership if needed to gitlab-psql: sudo chown -R gitlab-psql /var/opt/gitlab/postgresql

  5. Perform gitlab-ctl reconfigure, gitlab-ctl restart.

  6. Log into mattermost. Mattermost will work, but gitlab will not.

  7. Perform a mattermost backup.

  8. From there, I was able to take that backup and restore it on the primary server.