Backup database of a docker rootless instance

Hello! This is the man from the Frankenstein instance once again.
For those who don’t know what I’m talking about, I’m trying to use a rootless Docker instance with Docker secrets, a reverse proxy (I’m trying Traefik now but I’m open to suggestions), Keycloak as SSO, and Cloudflare.
Sounds like a big pile of problems, right? It’s okay, we learn for fun.

I can avoid the issue reported in the past when I restart the server (or Passbolt server container) causing an error by creating a symbolic link that avoids starting, by simply removing the server container before restarting the server. Remembering that, I can use the instance.

But, while I’m looking for a better solution for that (because it’s like a workaround but not ideal), I found something new that I would like to ask you in case I missed something.

I’m trying to back up the database as shown in this guide in case I break something (it’s possible) and automate it in the future, but I get this error:

user@host:~ $ docker exec -i passbolt_db bash -c \
'mysqldump -u${MYSQL_USER} -p${MYSQL_PASSWORD} ${MYSQL_DATABASE}' \
> ~/passbolt.sql
bash: line 1: mysqldump: command not found

I checked inside the Passbolt database and server containers looking for the mysql and mysqldump commands, but they are not present. Do you know how I can backup the database?

This is a part of my docker-compose in case you want to know the version or containers I’m using:

version: "3.9"
name: passbolt
services:
    passbolt_db:
        container_name: passbolt_db
        image: mariadb:latest
        restart: unless-stopped
        env_file:
            - mariadb.env
        ...

    passbolt_server:
        container_name: passbolt_server
        image: passbolt/passbolt:latest-pro-non-root
        restart: unless-stopped
        depends_on:
            - passbolt_db
        env_file:
            - passbolt.env
        ...

A couple potential options here:

  • Expose port 3306 from the container to the host and install mysql on the host so you can run the dump from the host
  • Add another container which has mariadb/mysql installed and run the dump from that container
  • Install the missing package on the database container

Those are the ways I would tackle it but I am using a mysql image mysql:8.0.31 and it has mysqldump

Those options should work, but I was looking for something in the images that would allow you to do that (which I assume doesn’t exist actually).
Do you think it’s possible to add some script or something to the rootless image to help backup the database?

Could you let me know which this actually is?

Just spun up a non root container with image: mariadb:10.11 and I had mysqldump on that container. The mariadb container isn’t non-root, just the passbolt one is.

For the record tested with with both the exec into the pod to run it and running the docker exec command with it all in one that you were trying, no issue on either

In theory, it is just the mariadb latest image downloaded from the Docker hub without modifying it.
I tried to pull it again just in case there was a bug or something solved in an update but it is still the same.
According to container logs, I have MariaDB 11.3.2-MariaDB-1:11.3.2+maria~ubu2204 source revision 068a6819eb63bcb01fdfa037c9bf3bf63c33ee42 version

I tried to run mariadb inside the container and it works as a client, so I’m checking the same as mysqldump but for mariadb

Found the issue, pulled latest. Try mariadb-dump

https://mariadb.com/kb/en/mysqldump/

1 Like

You were quicker than me writing hahahaha.
I tried mariadb-dump and it seems to work as mysqldump so I was able to use it with the same structure as the guide.
Now I can try to automate it, thank you @clayton

Maybe there can be a disclaimer in the guide to help others with mariadb

1 Like

Yep, posting that in our chat so we can add a ticket as mariadb is the default that we have in the docker compose so most will likely be on that, though we have it pinned below the breaking change here

1 Like

Great, so a battle won, the war continues hahahaha