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.
Verify the Migration
To confirm the migration was successful:
- Check Mattermost server logs for successful database connection
- Log into Mattermost and verify all teams, channels, and users are present
- Test posting messages and file uploads to ensure functionality
- Verify user authentication and permissions are working correctly
- Confirm database queries are running against the new PostgreSQL server
Comments
Article is closed for comments.