Mattermost - Help - Database

Discussion about various official QPKG software applications. Login required to view the contents.
Post Reply
fnxfnx
New here
Posts: 3
Joined: Sat Nov 13, 2021 4:15 pm

Mattermost - Help - Database

Post by fnxfnx »

Hi,

I'm sitting trying but I'm giving up. Please help.

I have Qnap 251d and on it Mattermost 5.0.0.7
Due to the fact that this is an old version I wanted to move to something higher such as: in Docker.
Here I have no problems everything works nicely including the internal database but...
How to backup database from this "factory" application?

I checked the files and here:
mattermost\volumes\db\var\lib\postgresql\data

According to me it holds the base. There are others in the base directory (probably with mattermost base) and lots of files there.

I tried on my computer to put in the same version: postgresql, then disable the service replace all the files and enable but then it crashes for me.

I tried connecting to qnap on port 5432 through the pgadmin application but it sees nothing.

In the docker-compose.yml file it is:

- MM_USERNAME=mmuser
- MM_PASSWORD=mmuser_password
- MM_DBNAME=mattermost

So I'm shooting that this is the data for the database.

Unfortunately despite various attempts I am not able to access it. I need to either get into the database or somehow convert the files to sql.

HELP.
User avatar
dolbyman
Guru
Posts: 35274
Joined: Sat Feb 12, 2011 2:11 am
Location: Vancouver BC , Canada

Re: Mattermost - Help - Database

Post by dolbyman »

never used the app but others seems to have the question as well

https://forum.mattermost.org/t/qnap-mat ... ackup/9870

so you currently have the qpkg (non container) running and no db is showing up in phpMyAdmin?
fnxfnx
New here
Posts: 3
Joined: Sat Nov 13, 2021 4:15 pm

Re: Mattermost - Help - Database

Post by fnxfnx »

Thank you for your reply.
dolbyman wrote: Sat Nov 13, 2021 11:51 pm never used the app but others seems to have the question as well

https://forum.mattermost.org/t/qnap-mat ... ackup/9870

so you currently have the qpkg (non container) running and no db is showing up in phpMyAdmin?
No.


It tipped me off to this:

Well okay I think I figured it out a little bit through other versions as well.

It looks like Mattermost is uploaded to the directory:
/share/CACHEDEV1_DATA/.qpkg/mattermost

But the database in postgres is in:
/share/CACHEDEV1_DATA/.qpkg/mattermost/volumes/db

but the application config is in:
/share/CACHEDEV1_DATA/.qpkg/mattermost/volumes/app/mattermost/config

In it we find the entry:
"DataSource": "postgres://mmuser:mmuser_password@db:5432/mattermost?sslmode=disable=u0026connect_timeout=10",

so we have the login credentials (me too before):
login:
mmuser
pass:
mmuser_password
database server name (instead of ip)
db
port:
5432

And up to this point it is ok.

Next the stairs start because it looks like postgres is somehow a Container Station but probably through that:


Code: Select all

version: "2"

services:

  db:
    image: mattermost/db:${BUILD_HASH}
    restart: unless-stopped
    volumes:
      - ./volumes/db/var/lib/postgresql/data:/var/lib/postgresql/data
      - ./flags:/flags
      - /etc/localtime:/etc/localtime:ro
    environment:
      - POSTGRES_USER=mmuser
      - POSTGRES_PASSWORD=mmuser_password
      - POSTGRES_DB=mattermost

  app:
    image: mattermost/app:${BUILD_HASH}
    depends_on:
      - db
    expose:
      - "${APP_PORT_NUMBER}"
    restart: unless-stopped
    volumes:
      - ./volumes/app/mattermost/config:/mattermost/config:rw
      - ./volumes/app/mattermost/data:/mattermost/data:rw
      - ./volumes/app/mattermost/logs:/mattermost/logs:rw
      - ./flags:/flags
      - /etc/localtime:/etc/localtime:ro
    environment:
      # set same as db credentials and dbname
      - MM_USERNAME=mmuser
      - MM_PASSWORD=mmuser_password
      - MM_DBNAME=mattermost
    links:
      - db:db
    
      system-docker exec -it mattermost_app_1 /bin/sh
  #
  # web:
  #  image: mattermost/web:${BUILD_HASH}
  #  depends_on:
  #    - db
  #    - app
  #  environment:
  #  - MATTERMOST_USE_SSL=${MATTERMOST_USE_SSL}
  #  - APP_PORT_NUMBER=${APP_PORT_NUMBER}
  #  - Forward80To443=${Forward80To443}
  #  ports:
  #    - "${MATTERMOST_HTTP}:80"
  #    - "${MATTERMOST_HTTPS}:443"
  #  restart: unless-stopped
  #  volumes:
  #    # This directory must have cert files
  #    - ./volumes/web/cert:/cert:ro
  #    - /etc/localtime:/etc/localtime:ro
  #  links:
  #    - app:app

networks:
  default:
    external:
      name: mattermost_app_network



to me it indicates that the database is not located in a directory somewhere Container Station but in:
/volumes/db/var/lib/

So we have it explained.

What is more, the application is written differently, because we have some things in the directory:
nginx

But now a problem arises.
We know theoretically that the database (postgres server) is located / started via container, but how to connect to it?
Via PuTTY or via some tool such as HeidiSQL by selecting postgresql FAQ SSH tunnel?

How to connect to it?
fnxfnx
New here
Posts: 3
Joined: Sat Nov 13, 2021 4:15 pm

Re: Mattermost - Help - Database

Post by fnxfnx »

-----------------------------
We did it!

Using putty I pasted the command:
system-docker exec -it mattermost_app_1 /bin/sh

I then pinged the name "db" is what appeared here:
"DataSource": "postgres://mmuser:mmuser_password@db:5432/mattermost?sslmode=disable=u0026connect_timeout=10",

This showed me the IP address:
172.30.68.2
It only responded once, every time.

On the Qnap in the virtual switch application I found Virtual switch, there I took off the nat and set the dns to Qnap and router.

Then I added routing on the computer:

route add 172.30.68.0 mask 255.255.255.0 Qnap's IP

From this point it pinged my IP:
172.30.68.2

Then using the program: HeidiSQL

I connected to this address on the port and data that are already known and it works.
I have access to the database!
QRocks
Starting out
Posts: 16
Joined: Thu Jun 17, 2021 12:39 am

Re: Mattermost - Help - Database

Post by QRocks »

Any chance to have an idea of to do a backup of the MM db ?
Thank you !
R.Wagner
New here
Posts: 2
Joined: Mon Feb 28, 2022 3:17 am

Re: Mattermost - Help - Database

Post by R.Wagner »

@fnxfnx
That is a great accomplishment.
Could you explain the last part more in detail?
I made it up to the IP of the database but then I lost the plot.
When I try to ping it, it shows

Code: Select all

PING 172.30.12.2 (172.30.12.2): 56 data bytes
ping: permission denied (are you root?)
Also the part with what you did on the Qnap with NAT I did not understand.
And what where your settings for the HeidiSQL connection?
Post Reply

Return to “Official Apps”