Wordpress_mariadb recipe improvements.
* Unified dumpdb_mysql.sh script. * Added the restoredb_mysql wrapper script. * Minimal changes in storage_backup script.
This commit is contained in:
@ -1,8 +1,8 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# A service script to backup the docker-composed WordPress instance.
|
||||
# Dumps the MySQL/MariaDB database to the $BASE_DIR/storage/backups/dumps
|
||||
# folder (by default). An optional parameter may change the target folder.
|
||||
# A service script to backup the docker-composed MySQL/MariaDB database.
|
||||
# Dumps database to the $BASE_DIR/storage/backups/dumps folder (by default).
|
||||
# An optional parameter may change the target folder.
|
||||
#
|
||||
# This script gets the database credentials from the docker-compose.yml file
|
||||
# and calls the mysql_dumpdb worker script which should be installed in
|
||||
@ -10,8 +10,11 @@
|
||||
#
|
||||
# Call as a Docker manager user (member of the docker Linux group) via cron.
|
||||
#
|
||||
# Author: Kovács Zoltán <kovacs.zoltan@smartfront.hu>
|
||||
# Author: Kovács Zoltán <kovacsz@marcusconsulting.hu>
|
||||
# Kovács Zoltán <kovacs.zoltan@smartfront.hu>
|
||||
# License: GNU/GPL 3+ https://www.gnu.org/licenses/gpl-3.0.en.html
|
||||
# 2025-02-26 v0.3
|
||||
# mod: doesn't tied to a particular composition (Mediawiki, Wordpress, etc).
|
||||
# 2024-12-01 v0.2.1
|
||||
# fix: typo in docker-compose version detection.
|
||||
# 2024-08-25 v0.2
|
||||
@ -22,6 +25,7 @@
|
||||
#
|
||||
PAR_BASEDIR=${PAR_BASEDIR:-""} # Service's base folder
|
||||
PAR_DUMPDIR=${PAR_DUMPDIR:-""} # Folder to dump within
|
||||
PAR_SERVICE=${PAR_SERVICE:-"database"} # Service's name in composition
|
||||
|
||||
# Messages (maybe overridden by configuration).
|
||||
#
|
||||
@ -111,7 +115,7 @@ DUMPDIR="${PAR_DUMPDIR:-$BASE_DIR/$DUMPDIR}"
|
||||
[[ ! -w "$DUMPDIR" ]] \
|
||||
&& echo "$MSG_NONWRITE: $DUMPDIR" >&2 && exit 1
|
||||
|
||||
# The service must be running - silently gives up here if not.
|
||||
# The composition must be running - silently gives up here if not.
|
||||
#
|
||||
[[ -z "$(cd "$BASE_DIR"; "$DOCKER_COMPOSE" $commandstring ps --services --filter "status=running")" ]] \
|
||||
&& exit 1
|
||||
@ -135,14 +139,14 @@ function parse { [[ -z "$1" ]] && return
|
||||
echo -e "$value"; return
|
||||
}
|
||||
# All parameters are mandatories.
|
||||
MYCONTAINER="$(parse "WORDPRESS_DB_HOST")"
|
||||
if [ -z "$MYCONTAINER" ]; then echo "$MSG_NOPARAM WORDPRESS_DB_HOST" >&2; exit 1; fi
|
||||
MYDATABASE="$(parse "WORDPRESS_DB_NAME")"
|
||||
if [ -z "$MYDATABASE" ]; then echo "$MSG_NOPARAM WORDPRESS_DB_NAME" >&2; exit 1; fi
|
||||
MYUSER="$(parse "WORDPRESS_DB_USER")"
|
||||
if [ -z "$MYUSER" ]; then echo "$MSG_NOPARAM WORDPRESS_DB_USER" >&2; exit 1; fi
|
||||
MYPASSWORD="$(parse "WORDPRESS_DB_PASSWORD")"
|
||||
if [ -z "$MYPASSWORD" ]; then echo "$MSG_NOPARAM WORDPRESS_DB_PASSWORD" >&2; exit 1; fi
|
||||
MYCONTAINER="$PAR_SERVICE" # TODO: guess from the yml
|
||||
if [ -z "$MYCONTAINER" ]; then echo "$MSG_NOPARAM PAR_SERVICE" >&2; exit 1; fi1; fi
|
||||
MYDATABASE="$(parse "MYSQL_DATABASE")"
|
||||
if [ -z "$MYDATABASE" ]; then echo "$MSG_NOPARAM MYSQL_DATABASE" >&2; exit 1; fi
|
||||
MYUSER="$(parse "MYSQL_USER")"
|
||||
if [ -z "$MYUSER" ]; then echo "$MSG_NOPARAM MYSQL_USER" >&2; exit 1; fi
|
||||
MYPASSWORD="$(parse "MYSQL_PASSWORD")"
|
||||
if [ -z "$MYPASSWORD" ]; then echo "$MSG_NOPARAM MYSQL_PASSWORD" >&2; exit 1; fi
|
||||
# We've the configuration parsed.
|
||||
|
||||
# Converts the database service name to an actual running container's name.
|
||||
|
Reference in New Issue
Block a user