From f93750070e1f1a5738b825f02fa3763d2c5ae0b1 Mon Sep 17 00:00:00 2001 From: Nicholas Alipaz Date: Wed, 27 Dec 2023 10:23:47 -0800 Subject: [PATCH 1/4] Add --on-demand and more verbosity when passing env flags --- scripts/acquia-pull.sh | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/scripts/acquia-pull.sh b/scripts/acquia-pull.sh index 4306cfa..8ce2a1c 100755 --- a/scripts/acquia-pull.sh +++ b/scripts/acquia-pull.sh @@ -38,6 +38,7 @@ while (( "$#" )); do fi ;; -c|--code|--code=*) + CODEFLAG=true if [ "${1##--code=}" != "$1" ]; then CODE="${1##--code=}" shift @@ -47,6 +48,7 @@ while (( "$#" )); do fi ;; -d|--database|--database=*) + DATABASEFLAG=true if [ "${1##--database=}" != "$1" ]; then DATABASE="${1##--database=}"; shift @@ -56,6 +58,7 @@ while (( "$#" )); do fi ;; -f|--files|--files=*) + FILEFLAG=true if [ "${1##--files=}" != "$1" ]; then FILES="${1##--files=}" shift @@ -72,6 +75,10 @@ while (( "$#" )); do NO_AUTH=true shift ;; + --on-demand) + ON_DEMAND=--on-demand + shift + ;; --) shift break @@ -94,11 +101,17 @@ fi # Get the codez if [ "$CODE" != "none" ]; then + if [ $CODEFLAG ]; then + echo -n "Using the code flag supplied to pull code from $CODE." + fi acli -n pull:code "$AH_SITE_GROUP.$CODE" fi # Get the database if [ "$DATABASE" != "none" ]; then + if [ $DATABASEFLAG ]; then + echo -n "Using the database flag supplied to pull the database from $DATABASE." + fi # Destroy existing tables # NOTE: We do this so the source DB **EXACTLY MATCHES** the target DB TABLES=$(mysql --user=acquia --password=acquia --database=acquia --host=database --port=3306 -e 'SHOW TABLES' | awk '{ print $1}' | grep -v '^Tables' ) || true @@ -115,7 +128,7 @@ EOF done # Importing database - acli -n pull:db "$AH_SITE_GROUP.$DATABASE" + acli -n pull:db "$AH_SITE_GROUP.$DATABASE"$ON_DEMAND # Weak check that we got tables PULL_DB_CHECK_TABLE=${LANDO_DB_USER_TABLE:-users} @@ -129,6 +142,9 @@ fi # Get the files if [ "$FILES" != "none" ]; then + if [ $FILESFLAG ]; then + echo -n "Using the files flag supplied to pull files from $FILES." + fi # acli -n pull:files "$FILES" -> non interactive causes a broken pipe error right now acli -n pull:files "$AH_SITE_GROUP.$FILES" fi From d2dce44f8ca2b56e5bccbb242fc5cd158da66acf Mon Sep 17 00:00:00 2001 From: Nicholas Alipaz Date: Wed, 27 Dec 2023 10:34:43 -0800 Subject: [PATCH 2/4] Add a space in front of `--on-demand` --- scripts/acquia-pull.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/acquia-pull.sh b/scripts/acquia-pull.sh index 8ce2a1c..03b8a88 100755 --- a/scripts/acquia-pull.sh +++ b/scripts/acquia-pull.sh @@ -76,7 +76,7 @@ while (( "$#" )); do shift ;; --on-demand) - ON_DEMAND=--on-demand + ON_DEMAND=" --on-demand" shift ;; --) From 1a88143bececdea15e49db2b41a0fcd9211bfb96 Mon Sep 17 00:00:00 2001 From: Nicholas Alipaz Date: Wed, 27 Dec 2023 10:45:08 -0800 Subject: [PATCH 3/4] Document `--on-demand` flag --- docs/sync.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/sync.md b/docs/sync.md index 7ac8772..00319c7 100644 --- a/docs/sync.md +++ b/docs/sync.md @@ -30,6 +30,9 @@ lando pull --code=none --database=dev --files=none # Attempt a pull using a different key and secret lando pull --key "$ACQUIA_KEY" --secret "$ACQUIA_SECRET" + +# Use the on-demand flag to generate a new database copy before pulling +lando pull --on-demand ``` #### Options @@ -41,6 +44,7 @@ lando pull --key "$ACQUIA_KEY" --secret "$ACQUIA_SECRET" --files, -f The environment from which to pull the files --key An Acquia API key --secret An Acquia API secret +--on-demand Generate a fresh database export when pulling the database ``` Please consult the manual import documentation below if this command produces an error. From 2976ca69477494894cf81d87d4d4a3e0979874c8 Mon Sep 17 00:00:00 2001 From: Nicholas Alipaz Date: Wed, 27 Dec 2023 10:50:09 -0800 Subject: [PATCH 4/4] Add on-demand to pull.js --- lib/pull.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/pull.js b/lib/pull.js index d827155..1adf558 100644 --- a/lib/pull.js +++ b/lib/pull.js @@ -86,6 +86,10 @@ const task = { weight: 400, }, }, + 'on-demand': { + description: 'Generate a new backup of the database when pulling', + passthrough: true, + }, }, };