Skip to content
Open
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
4 changes: 4 additions & 0 deletions docs/sync.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand Down
4 changes: 4 additions & 0 deletions lib/pull.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ const task = {
weight: 400,
},
},
'on-demand': {
description: 'Generate a new backup of the database when pulling',
passthrough: true,
},
},
};

Expand Down
18 changes: 17 additions & 1 deletion scripts/acquia-pull.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ while (( "$#" )); do
fi
;;
-c|--code|--code=*)
CODEFLAG=true
if [ "${1##--code=}" != "$1" ]; then
CODE="${1##--code=}"
shift
Expand All @@ -47,6 +48,7 @@ while (( "$#" )); do
fi
;;
-d|--database|--database=*)
DATABASEFLAG=true
if [ "${1##--database=}" != "$1" ]; then
DATABASE="${1##--database=}";
shift
Expand All @@ -56,6 +58,7 @@ while (( "$#" )); do
fi
;;
-f|--files|--files=*)
FILEFLAG=true
if [ "${1##--files=}" != "$1" ]; then
FILES="${1##--files=}"
shift
Expand All @@ -72,6 +75,10 @@ while (( "$#" )); do
NO_AUTH=true
shift
;;
--on-demand)
ON_DEMAND=" --on-demand"
shift
;;
--)
shift
break
Expand All @@ -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
Expand All @@ -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}
Expand All @@ -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
Expand Down