From 208d535d958ff7250bfd035422383e20db813460 Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Mon, 1 Jun 2020 12:38:58 +0100 Subject: [PATCH] Add pull-from-prod to Makefile Add `pull-from-prod` to the Makefile, which downloads a database from production, imports it and runs the post-import steps. Fixes #79 --- Makefile | 14 ++++++++++++++ tools/ansible/download-database.yml | 9 +++------ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index ce637a8..0d806d1 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,5 @@ +SHELL=/bin/bash -e -o pipefail + .PHONY: * phpcs: @@ -20,6 +22,18 @@ phpstan: phpunit: vendor/bin/phpunit web/modules/custom +pull-from-prod: + # Download and import the database. + ansible-playbook tools/ansible/download-database.yml + zcat < dump.sql.gz | bin/drush.sh sql-cli + rm dump.sql.gz + + # Post import steps. + bin/drush.sh sql-sanitize -y --sanitize-password=password + bin/drush.sh updatedb -y + bin/drush.sh cache-rebuild + bin/drush.sh user-login 1 + start: docker-compose up -d symfony server:start -d diff --git a/tools/ansible/download-database.yml b/tools/ansible/download-database.yml index 1574289..9173a6d 100644 --- a/tools/ansible/download-database.yml +++ b/tools/ansible/download-database.yml @@ -6,13 +6,10 @@ vars_files: - vars/vars.yml - tasks: - - name: Generate the name for the export - set_fact: - export_filename: "~/{{ lookup('pipe', 'date -u +%Y%m%d%H%M%SZ') }}.sql" - run_once: true - when: export_filename is not defined + vars: + export_filename: /tmp/dump.sql + tasks: - name: Export the database command: cmd: >