Skip to content

Commit

Permalink
Added db-dump-sanitized.sh script
Browse files Browse the repository at this point in the history
  • Loading branch information
nicksantamaria committed Dec 5, 2023
1 parent 155ef54 commit bc21409
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
1 change: 1 addition & 0 deletions images/php/Dockerfile.cli
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ COPY redis-cluster.services.yml /bay
COPY redis-single.services.yml /bay
COPY settings.php /bay
COPY db-build.sh /bay
COPY db-dump-sanitized.sh /bay
COPY mtk /bay/mtk

# Change worker pool from dynamic to static. Change default value to 24.
Expand Down
7 changes: 1 addition & 6 deletions images/php/db-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,7 @@ cleanup() {
if [[ "${BASH_SOURCE[0]}" = "$0" ]]; then
trap cleanup EXIT
info "creating sanitized database dump with mtk - https://github.com/skpr/mtk"
mtk dump \
--user "${MARIADB_USERNAME}" \
--password "${MARIADB_PASSWORD}" \
--port "${MARIADB_PORT}" \
--host "${MARIADB_HOST}" \
"${MARIADB_DATABASE}" > "${DB_TEMPORARY_FILE}" || fatal "failed to dump database"
/bay/db-dump-sanitized.sh > "${DB_TEMPORARY_FILE}" || fatal "failed to dump database"

info "pushing database dump to s3 - ${S3_OBJECT_PATH}"
aws s3 cp --no-progress "${DB_TEMPORARY_FILE}" "${S3_OBJECT_PATH}" || fatal "failed to push dump to s3"
Expand Down
17 changes: 17 additions & 0 deletions images/php/db-dump-sanitized.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'

#/ Usage: ./db-dump-sanitized.sh
#/ Description: dumps a sanitized database to stdout
#/ Options:
#/ --help: Display this help message
usage() { grep '^#/' "$0" | cut -c4- ; exit 0 ; }
expr "$*" : ".*--help" > /dev/null && usage

mtk dump \
--user "${MARIADB_USERNAME}" \
--password "${MARIADB_PASSWORD}" \
--port "${MARIADB_PORT}" \
--host "${MARIADB_HOST}" \
"${MARIADB_DATABASE}"

0 comments on commit bc21409

Please sign in to comment.