diff --git a/src/_base/harness/config/commands.yml b/src/_base/harness/config/commands.yml index a8f56e506..53cb09887 100644 --- a/src/_base/harness/config/commands.yml +++ b/src/_base/harness/config/commands.yml @@ -315,3 +315,10 @@ command('lighthouse [--with-results]'): exec: | #!bash(workspace:/)|@ passthru docker-compose run --rm lighthouse bash -i /app/run.sh + +command('db dump sanitised'): + env: + COMPOSE_PROJECT_NAME: = @('namespace') + exec: | + #!bash(workspace:/) + passthru docker-compose exec -u build console /app/tools/database/dump_sanitised.sh \ No newline at end of file diff --git a/src/drupal8/application/skeleton/tools/database/dump_sanitised.sh b/src/drupal8/application/skeleton/tools/database/dump_sanitised.sh new file mode 100644 index 000000000..e829f2a9e --- /dev/null +++ b/src/drupal8/application/skeleton/tools/database/dump_sanitised.sh @@ -0,0 +1,34 @@ +#!/usr/bin/env bash + +set -e -o pipefail + +curl --fail --silent --show-error --location --output /tmp/mtk-dump https://github.com/skpr/mtk/releases/download/v0.0.1/mtk-dump_linux_amd64 +chmod +x /tmp/mtk-dump + +if [ -L "$0" ] ; then + DIR="$(dirname "$(readlink -f "$0")")" ; +else + DIR="$(dirname "$0")" ; +fi + +# Workspace (default). +BACKUP_DIR="/app/tools/assets/development" + +# Acquia. +if [[ -n "$AH_SITE_ENVIRONMENT" ]]; then + BACKUP_DIR="/mnt/files/$AH_SITE_NAME.$AH_SITE_ENVIRONMENT/backups/sanitised" +fi + +# Platform.sh. +if [[ -n "$PLATFORM_BRANCH" ]]; then + BACKUP_DIR="~/drush-backups/sanitised" +fi + +BACKUP_FILE="$BACKUP_DIR/dump_sanitised.sql" + +/tmp/mtk-dump \ +--config=$DIR/mtk.config.yml \ +--host=$DB_HOST \ +--user=$DB_USER \ +--password=$DB_PASS \ +$DB_NAME > $BACKUP_FILE \ No newline at end of file diff --git a/src/drupal8/application/skeleton/tools/database/mtk.config.yml b/src/drupal8/application/skeleton/tools/database/mtk.config.yml new file mode 100644 index 000000000..34962ffd7 --- /dev/null +++ b/src/drupal8/application/skeleton/tools/database/mtk.config.yml @@ -0,0 +1,22 @@ +--- +rewrite: + users_field_data: + mail: concat(uid, "@localhost") + pass: '"password"' + +nodata: + - cache* + - captcha_sessions + - history + - flood + - batch + - queue + - sessions + - semaphore + - search_api_task + - search_dataset + - search_index + - search_total + +ignore: + - __ACQUIA_MONITORING__ \ No newline at end of file