Use shared abra backup functions

This commit is contained in:
3wc 2021-03-02 18:36:51 +02:00
parent 4eaa4de5ae
commit aae6b22d53

31
abra.sh
View File

@ -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() {