Migrate MariaDB from native to Docker
This guide describes two options:
- Option A: Relution and the database run on the same server. MariaDB is added as a service to the Relution Docker setup →.
- Option B: The database runs on a dedicated server. MariaDB is operated there as a standalone container.
Prerequisites
- Docker is installed according to the recommended Docker installation →.
- The MariaDB image has the same major version as the native MariaDB.
Export the native database
Relution is stopped on the Relution server:
docker stop relution
The database is exported on the database server:
mariadb-dump -u root -p \
--single-transaction --quick \
--routines --triggers --events \
--hex-blob --default-character-set=utf8mb4 \
--max_allowed_packet=1G \
relution > /root/relution.sql
tail -1 /root/relution.sql
The last line must contain -- Dump completed.
Stop the native MariaDB
The native service is stopped and disabled on the database server:
systemctl disable --now mariadb
Option A: Relution and database on one server
In /opt/relution/compose.yaml, the database service is replaced with mariadb:
services:
mariadb:
image: mariadb:10.11
restart: unless-stopped
container_name: docker_mariadb
environment:
TZ: "Europe/Berlin"
MARIADB_ROOT_PASSWORD: "<ROOT_PASSWORD>"
MARIADB_DATABASE: "relution"
MARIADB_USER: "relution"
MARIADB_PASSWORD: "<RELUTION_DB_PASSWORD>"
volumes:
- 'mariadb:/var/lib/mysql'
networks:
database:
aliases:
- mariadb-docker
In the relution service, the depends_on entry database is replaced with mariadb. The volume is added under volumes::
volumes:
mariadb:
The database connection is adjusted in /opt/relution/application.yml:
relution:
database:
type: mariadb
url: jdbc:mariadb://mariadb-docker:3306/relution
username: relution
password: <RELUTION_DB_PASSWORD>
The container is then started:
cd /opt/relution
docker compose up -d mariadb
docker compose logs -f mariadb
As soon as ready for connections appears, the log output is closed with Ctrl+C and the database is imported:
docker exec -i docker_mariadb sh -c 'exec mariadb -uroot -p"$MARIADB_ROOT_PASSWORD" relution' < /root/relution.sql
Relution is then started:
docker compose up -d
docker logs -f relution
Option B: Database on a dedicated server
On the database server, /opt/mariadb/compose.yaml is created:
services:
mariadb:
image: mariadb:10.11
restart: unless-stopped
container_name: docker_mariadb
environment:
TZ: "Europe/Berlin"
MARIADB_ROOT_PASSWORD: "<ROOT_PASSWORD>"
MARIADB_DATABASE: "relution"
MARIADB_USER: "relution"
MARIADB_PASSWORD: "<CURRENT_RELUTION_DB_PASSWORD>"
ports:
- "3306:3306"
volumes:
- 'mariadb:/var/lib/mysql'
volumes:
mariadb:
Port 3306 is opened in the firewall for the Relution server only.
The container is then started:
cd /opt/mariadb
docker compose up -d
docker compose logs -f mariadb
As soon as ready for connections appears, the log output is closed with Ctrl+C and the database is imported:
docker exec -i docker_mariadb sh -c 'exec mariadb -uroot -p"$MARIADB_ROOT_PASSWORD" relution' < /root/relution.sql
Relution is then started on the Relution server:
docker start relution
docker logs -f relution
Since the server, port, user and password stay the same, the Relution application.yml does not need to be changed.
Migration to PostgreSQL
The further migration is described in Migration from MariaDB to PostgreSQL →.