Migrating Mattermost DB from GitLab Omnibus PostgreSQL installation to a standalone PostgreSQL

 

This article provides step-by-step instructions for migrating your Mattermost database from a GitLab Omnibus PostgreSQL installation to a standalone PostgreSQL server. This migration is commonly needed when separating Mattermost from GitLab or moving to dedicated database infrastructure.

Prerequisites

  • Administrative access to the GitLab server running the Omnibus installation
  • A new PostgreSQL server prepared and accessible
  • Sufficient disk space for database dump creation
  • Planned maintenance window for Mattermost downtime
  • Current backup of your Mattermost database

Migration Scenario

Organizations often need to migrate their Mattermost database from GitLab Omnibus to a standalone PostgreSQL server for various operational reasons, such as separating services, improving performance, or meeting compliance requirements.

When This Migration is Needed

You may need this migration when:

  • Moving Mattermost to a separate server from GitLab
  • Upgrading to dedicated PostgreSQL infrastructure
  • Implementing database clustering or high availability
  • Meeting organizational requirements for service separation
  • Optimizing database performance with dedicated resources

Migration Steps

Follow these steps to safely migrate your Mattermost database from GitLab Omnibus PostgreSQL to a standalone PostgreSQL server. Ensure you have a maintenance window planned as this process requires Mattermost downtime.

Step 1: Create Database Dump from GitLab

First, create a dump of your Mattermost database from the GitLab Omnibus PostgreSQL instance. This command connects to the embedded PostgreSQL and exports the mattermost_production database.

gitlab-psql -- /opt/embedded/bin/pg_dump -h /var/opt/gitlab/postgresql --no-owner mattermost_production | gzip mattermost_dbdump_$(date --rfc-3339=date).sql.gz 

Step 2: Prepare Your New PostgreSQL Database

Set up your new PostgreSQL server following the official Mattermost database preparation guidelines. This includes creating the database, user, and setting proper permissions.

Follow the detailed instructions at: Mattermost Database Preparation Guide

Step 3: Restore the Database Dump

Transfer the database dump to your new PostgreSQL server and restore it. Replace /tmp/mattermost_dbdump.sql.gz with the actual path to your dump file.

zcat /tmp/mattermost_dbdump.sql.gz | psql -U mmuser -d mattermost 

Step 4: Update Mattermost Configuration

Update your Mattermost config.json file to point to the new database server. Locate the SqlSettings.DataSource parameter and update it with your new database connection details.

Example DataSource format:

"DataSource": "postgres://mmuser:password@new-postgres-server:5432/mattermost?sslmode=disable&connect_timeout=10" 

Step 5: Start Mattermost

Start your Mattermost server to apply the new database configuration. Mattermost will now connect to your standalone PostgreSQL server instead of the GitLab Omnibus database.

⚠️ Important: Always create a complete backup of your Mattermost database before starting this migration process. Plan for Mattermost downtime during the migration. Test the database connection and verify all data integrity after the migration is complete. Ensure your new PostgreSQL server has adequate resources and proper security configurations.

Verify the Migration

To confirm the migration was successful:

  1. Check Mattermost server logs for successful database connection
  2. Log into Mattermost and verify all teams, channels, and users are present
  3. Test posting messages and file uploads to ensure functionality
  4. Verify user authentication and permissions are working correctly
  5. Confirm database queries are running against the new PostgreSQL server

 

Was this article helpful?
0 out of 0 found this helpful

Comments

0 comments

Article is closed for comments.