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:
@@ -9,6 +9,8 @@
|
||||
#
|
||||
# Author: Kovács Zoltán <kovacs.zoltan@smartfront.hu>
|
||||
# License: GNU/GPL 3+ https://www.gnu.org/licenses/gpl-3.0.en.html
|
||||
# 2025-03-05 v0.2.1
|
||||
# mod: reworded some comments and renamed a variable.
|
||||
# 2024-08-25 v0.2
|
||||
# new: docker-compose v2 compatibility - tested with Ubuntu 24.04 LTS.
|
||||
# 2021-10-19 v0.1 Initial version.
|
||||
@@ -25,7 +27,7 @@ MSG_DOESNOTRUN="This service doesn't run."
|
||||
MSG_MISSINGDEP="Fatal: missing dependency"
|
||||
MSG_MISSINGYML="Fatal: didn't find the docker-compose.yml file"
|
||||
MSG_NONWRITE="The target directory isn't writable"
|
||||
MSG_NOLOCATE="Cannot locate the Mediawiki container."
|
||||
MSG_NOLOCATE="Cannot locate the service container."
|
||||
|
||||
# Other initialisations.
|
||||
#
|
||||
@@ -108,16 +110,16 @@ BACKUPDIR="${PAR_BACKUPDIR:-$BASE_DIR/$BACKUPDIR}"
|
||||
[[ -z "$(cd "$BASE_DIR"; "$DOCKER_COMPOSE" $commandstring ps --services --filter "status=running")" ]] \
|
||||
&& exit 1
|
||||
|
||||
# Converts the WordPress service name to an actual running container's name.
|
||||
# Converts the service name to an actual running container's name.
|
||||
#
|
||||
WPCONTAINER="$("$DOCKER" inspect -f '{{.Name}}' $(cd "$BASE_DIR"; "$DOCKER_COMPOSE" $commandline ps -q "$SERVICENAME") | "$CUT" -c2-)"
|
||||
MYCONTAINER="$("$DOCKER" inspect -f '{{.Name}}' $(cd "$BASE_DIR"; "$DOCKER_COMPOSE" $commandline ps -q "$SERVICENAME") | "$CUT" -c2-)"
|
||||
# Gives up here if failed.
|
||||
if [ -z "$WPCONTAINER" ]; then echo "$MSG_NOLOCATE" >&2; exit 1; fi
|
||||
if [ -z "$MYCONTAINER" ]; then echo "$MSG_NOLOCATE" >&2; exit 1; fi
|
||||
|
||||
# Tries the FS backup.
|
||||
if [ -w "$BACKUPDIR" ]; then
|
||||
BACKUP_NAME=$WPCONTAINER.$("$DATE" '+%Y%m%d_%H%M%S').$("$HOSTNAME")
|
||||
"$DOCKER" exec $WPCONTAINER sh \
|
||||
BACKUP_NAME=$MYCONTAINER.$("$DATE" '+%Y%m%d_%H%M%S').$("$HOSTNAME")
|
||||
"$DOCKER" exec $MYCONTAINER sh \
|
||||
-c "cd /var/www/html; tar cz ." \
|
||||
> "$BACKUPDIR/$BACKUP_NAME.tgz" 2>>"$BACKUPDIR/$BACKUP_NAME.log"
|
||||
fi
|
||||
|
Reference in New Issue
Block a user