Moving gitlab mattermost between instances

Hi,

I just moved gitlab 11.0.2 from a Debian 7 to a Ubuntu 18.04 host using the guide at https://docs.gitlab.com/ee/raketasks/backup_restore.html.

Things seem to be working okay, but mattermost data hasn’t moved. How would I backup and restore mattermost data when moving between hosts?

Thanks

This is what I tried, and it seems to work somewhat, but I’m not sure if there is a better way.

On the old host

  1. Backup database
    sudo -u mattermost /opt/gitlab/embedded/bin/pg_dump -U gitlab_mattermost -h /var/opt/gitlab/postgresql -p 5432 mattermost_production > /home/gitlab/mattermost/mattermost_production_backup.sql

  2. Backup files
    sudo cp -R /var/opt/gitlab/mattermost/* /home/gitlab/mattermost/data

  3. Package files
    tar -zcf /home/gitlab//mattermost.tar.gz /home/gitlab/mattermost/

On the new host

  1. Stop gitlab: sudo gitlab-ctl stop

  2. Start postgresql: sudo gitlab-ctl start postgresql

  3. Drop the existing mattermost database

    sudo -u mattermost /opt/gitlab/embedded/bin/dropdb -U gitlab_mattermost -h /var/opt/gitlab/postgresql -p 5432 mattermost_production

  4. Create a new mattermost database
    sudo -u gitlab-psql /opt/gitlab/embedded/bin/createdb -U gitlab-psql -h /var/opt/gitlab/postgresql -p 5432 mattermost_production

  5. Restore database
    sudo -u mattermost /opt/gitlab/embedded/bin/psql -U gitlab_mattermost -h /var/opt/gitlab/postgresql -p 5432 mattermost_production < /home/gitlab/mattermost_backup/mattermost_production_backup.sql

  6. Restore files

  • after restoring files, make sure they are owned by the mattermost user.
    sudo chown -R mattermost /var/opt/gitlab/mattermost/
1 Like