brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: MARIADB_AUTO_UPGRADE=1 lets the MariaDB image upgrade the database system tables itself

Database
~/tips/tip-database-mariadb-docker-auto-upgrade

services:

Has the official image run mariadb-upgrade and back up system tables after a version bump.

After you bump the MariaDB image to a new major version, the system tables in the mysql schema are still in the old format. The server starts anyway and then logs warnings until someone runs mariadb-upgrade.

The official image can do that step on its own:

services:
  db:
    image: mariadb:11.4
    environment:
      MARIADB_AUTO_UPGRADE: "1"

On start, the entrypoint checks whether the data directory came from an older version. If so, it starts a temporary server, writes a backup of the mysql system database to a file named like system_mysql_backup_<old version>.sql.zst in the data directory, runs mariadb-upgrade and then starts normally. That is how the entrypoint script of the image works, and the Docker Hub page describes it too.

It also creates the healthcheck user if the volume is older than that feature, which is why I’d turn it on for existing volumes.

That small backup covers users and grants, not your own tables. Take a real dump before you change the image tag. And skipping major versions is still a risk the variable cannot fix, so read the release notes for each step. If you want no upgrade backup at all, MARIADB_DISABLE_UPGRADE_BACKUP=1 turns it off, but I would leave it on.

Further reading: mariadb on Docker Hub, mariadb-upgrade

More Database tips mariadb -e 'CREATE DATABASE IF NOT EXISTS blog' mariadb-dump --no-create-info --insert-ignore shop orders > orders-rows.sql SELECT table_schema, table_name, CHECKSUM TABLE shop.orders; services: All Database tips (53) All topics

Link