From aae6b22d53d994a5582dd4008fbd779981a4bb0f Mon Sep 17 00:00:00 2001 From: 3wc <3wc.git@doesthisthing.work> Date: Tue, 2 Mar 2021 18:36:51 +0200 Subject: [PATCH] Use shared abra backup functions --- abra.sh | 31 ++++--------------------------- 1 file changed, 4 insertions(+), 27 deletions(-) diff --git a/abra.sh b/abra.sh index 98c57e2..66a00db 100644 --- a/abra.sh +++ b/abra.sh @@ -11,39 +11,16 @@ sub_wp() { error "Can't find a container for ${STACK_NAME}_app" exit fi - # shellcheck disable=SC2154,SC2086 - docker run -it --volumes-from "$CONTAINER" --network "container:$CONTAINER" wordpress:cli wp ${abra__args_[*]} + # shellcheck disable=SC2154,SC2086 + docker run -it --volumes-from "$CONTAINER" --network "container:$CONTAINER" wordpress:cli wp ${abra__args_[*]} } abra_backup_app() { - # shellcheck disable=SC2034 - { - abra__src_="app:/var/www/html/wp-content" - abra__dst_="-" - } - - # shellcheck disable=SC2154 - FILENAME="$ABRA_DIR/backups/${abra__app_}_wp-content_$(date +%F).tar.gz" - - sub_app_cp | gzip > "$FILENAME" - - success "Backed up 'app' to $FILENAME" + _abra_backup_dir "app:/var/www/html/wp-content" } abra_backup_db() { - # shellcheck disable=SC2034 - abra__service_="db" - # 3wc: necessary because $abra__service_ won't be set if we're coming from - # `abra_backup`, i.e. `abra app ... backup --all` - - DB_ROOT_PASSWORD=$(sub_app_run cat /run/secrets/db_root_password) - - # shellcheck disable=SC2154 - FILENAME="$ABRA_DIR/backups/${abra__app_}_$(date +%F).sql.gz" - - sub_app_run mysqldump -u root -p"$DB_ROOT_PASSWORD" wordpress | gzip > "$FILENAME" - - success "Backed up 'db' to $FILENAME" + _abra_backup_mysql "db" "wordpress" } abra_backup() {