Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sanitised database dump tool to drupal websites. #577

Draft
wants to merge 7 commits into
base: 1.6.x
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/_base/harness/config/commands.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
34 changes: 34 additions & 0 deletions src/drupal8/application/skeleton/tools/database/dump_sanitised.sh
Original file line number Diff line number Diff line change
@@ -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
22 changes: 22 additions & 0 deletions src/drupal8/application/skeleton/tools/database/mtk.config.yml
Original file line number Diff line number Diff line change
@@ -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__