From c4f18608a146739b61b19de444667c1ac62c4dbd Mon Sep 17 00:00:00 2001 From: Mathieu Dubois-Briand Date: Mon, 24 Feb 2025 11:59:31 +0100 Subject: [PATCH] dockersetup: Switch from mysql to mariadb binaries In the last versions of mariadb:lts docker container, the database management binaries are named mariadb* instead of mysql*. This requires some small modifications in our scripts. Signed-off-by: Mathieu Dubois-Briand Signed-off-by: Michael Halstead --- README | 4 ++-- dockersetup.py | 6 +++--- layerindex/tools/initial_db_dump.sh | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/README b/README index 89dbd5b..1335b7a 100644 --- a/README +++ b/README @@ -412,12 +412,12 @@ To back up the database within the docker-based setup, you can run the following command (no need to substitute ${MYSQL_ROOT_PASSWORD}, it's already present within the container environment): -docker-compose exec layersdb /bin/sh -c '/usr/bin/mysqldump -u root --password=${MYSQL_ROOT_PASSWORD} --max_allowed_packet=512M layersdb' | gzip > backup-`date +%Y_%m_%d_%H%M`.sql.gz +docker-compose exec layersdb /bin/sh -c '/usr/bin/mariadb-dump -u root --password=${MYSQL_ROOT_PASSWORD} --max_allowed_packet=512M layersdb' | gzip > backup-`date +%Y_%m_%d_%H%M`.sql.gz To restore one of these backups you would run the following command (take care, this will overwrite the data immediately without prompting!): -zcat backupfile.sql.gz | docker-compose exec -T layersdb /bin/sh -c '/usr/bin/mysql -u root --password=${MYSQL_ROOT_PASSWORD} layersdb' +zcat backupfile.sql.gz | docker-compose exec -T layersdb /bin/sh -c '/usr/bin/mariadb -u root --password=${MYSQL_ROOT_PASSWORD} layersdb' diff --git a/dockersetup.py b/dockersetup.py index 21be0da..bc7478c 100755 --- a/dockersetup.py +++ b/dockersetup.py @@ -798,7 +798,7 @@ while True: env = os.environ.copy() env['MYSQL_PWD'] = dbapassword # Dummy command, we just want to establish that the db can be connected to - return_code = subprocess.call("echo | docker-compose exec -T -e MYSQL_PWD layersdb mysql -uroot layersdb", shell=True, env=env) + return_code = subprocess.call("echo | docker-compose exec -T -e MYSQL_PWD layersdb mariadb -uroot layersdb", shell=True, env=env) if return_code == 0: break else: @@ -820,7 +820,7 @@ if not args.update: catcmd = 'cat' env = os.environ.copy() env['MYSQL_PWD'] = dbapassword - return_code = subprocess.call("%s %s | docker-compose exec -T -e MYSQL_PWD layersdb mysql -uroot layersdb" % (catcmd, quote(args.databasefile)), shell=True, env=env) + return_code = subprocess.call("%s %s | docker-compose exec -T -e MYSQL_PWD layersdb mariadb -uroot layersdb" % (catcmd, quote(args.databasefile)), shell=True, env=env) if return_code != 0: print("Database import failed") sys.exit(1) @@ -848,7 +848,7 @@ if not args.update: # (avoids password being visible through ps or /proc//cmdline) env = os.environ.copy() env['MYSQL_PWD'] = dbapassword - return_code = subprocess.call("docker-compose exec -T -e MYSQL_PWD layersdb mysql -uroot layersdb < " + quote(sqlscriptfile), shell=True, env=env) + return_code = subprocess.call("docker-compose exec -T -e MYSQL_PWD layersdb mariadb -uroot layersdb < " + quote(sqlscriptfile), shell=True, env=env) if return_code != 0: print("Creating database user failed") sys.exit(1) diff --git a/layerindex/tools/initial_db_dump.sh b/layerindex/tools/initial_db_dump.sh index 1675092..a8648c6 100755 --- a/layerindex/tools/initial_db_dump.sh +++ b/layerindex/tools/initial_db_dump.sh @@ -31,9 +31,9 @@ fi # This will ask for the password twice, not much we can really do about # that though # First, get the structure without data -mysqldump $1 -u root -p --no-data > $2 +mariadb-dump $1 -u root -p --no-data > $2 # Second, the data with a number of exclusions -mysqldump $1 -u root -p --no-create-info \ +mariadb-dump $1 -u root -p --no-create-info \ --ignore-table=$1.auth_group \ --ignore-table=$1.auth_group_permissions \ --ignore-table=$1.auth_permission \