-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from wunderio/feature/11-Create-syncdb-task-to…
…-sync-wunder-production-db-to-local #11 Add syncdb command.
- Loading branch information
Showing
12 changed files
with
93 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/usr/bin/env bash | ||
|
||
## Description: Synchronise local database with production. | ||
## Usage: syncdb | ||
## Example: "ddev syncdb" | ||
|
||
|
||
.ddev/wunderio/core/_run-scripts.sh tooling-syncdb.sh "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/usr/bin/env bash | ||
|
||
## Description: Runs yq commands (yq is a lightweight and portable command-line YAML processor). | ||
## Usage: yq | ||
## Example: "ddev yq" | ||
|
||
yq "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/bin/bash | ||
|
||
# | ||
# Helper functions. | ||
# | ||
|
||
set -eu | ||
if [[ -n "${WUNDERIO_DEBUG:-}" ]]; then | ||
set -x | ||
fi | ||
export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/var/www/html/vendor/bin | ||
|
||
# Function to display status message | ||
display_status_message() { | ||
local color_green="\033[38;5;70m" | ||
local color_reset="\033[0m" | ||
local message="$1" | ||
|
||
printf "${color_green}${message}${color_reset}\n" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,18 @@ | ||
#!/bin/sh | ||
#!/bin/bash | ||
|
||
# | ||
# Helper script to run posb-import db hook. | ||
# | ||
|
||
set -eu | ||
if [ -n "${WUNDERIO_DEBUG:-}" ]; then | ||
if [[ -n "${WUNDERIO_DEBUG:-}" ]]; then | ||
set -x | ||
fi | ||
export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/var/www/html/vendor/bin | ||
|
||
cd $DDEV_COMPOSER_ROOT && drush cache:rebuild -y && drush @local user:login | ||
source /var/www/html/.ddev/wunderio/core/_helpers.sh | ||
|
||
cd $DDEV_COMPOSER_ROOT && drush cache:rebuild -y && drush sqlsan -y | ||
|
||
uli_link=$(drush uli) | ||
display_status_message "Drupal is working, running drush uli: $uli_link" |
4 changes: 2 additions & 2 deletions
4
dist/.ddev/wunderio/core/hooks-host-post-start.sh
100644 → 100755
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
#!/bin/sh | ||
#!/bin/bash | ||
|
||
# | ||
# Helper script to run host post-start commands. | ||
# | ||
|
||
set -eu | ||
if [ -n "${WUNDERIO_DEBUG:-}" ]; then | ||
if [[ -n "${WUNDERIO_DEBUG:-}" ]]; then | ||
set -x | ||
fi | ||
export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
dist/.ddev/wunderio/core/tooling-regenerate-phpunit-config.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/bin/bash | ||
|
||
# | ||
# Synchronise local database with the production environment. | ||
# | ||
# Based on https://github.com/wunderio/unisport/blob/master/.lando/syncdb.sh | ||
# | ||
|
||
set -eu | ||
if [[ -n "${WUNDERIO_DEBUG:-}" ]]; then | ||
set -x | ||
fi | ||
export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin | ||
|
||
source .ddev/wunderio/core/_helpers.sh | ||
|
||
sql_file="prod-syncdb-$(date +'%Y-%m-%d').sql" | ||
|
||
# Read the production alias from the drush configuration. | ||
# For some reason "ddev drush sql-sync @prod @local -y" does not work and times out. | ||
prod_alias=$(ddev drush sa @prod) | ||
prod_ssh_user=$(echo "$prod_alias" | ddev yq '.\"@self.prod\".user' ) | ||
prod_ssh_options=$(echo "$prod_alias" | ddev yq '.\"@self.prod\".ssh.options' ) | ||
prod_ssh_host=$(echo "$prod_alias" | ddev yq '.\"@self.prod\".host' ) | ||
|
||
set -x | ||
ssh "$prod_ssh_user@$prod_ssh_host" "$prod_ssh_options" "drush sql-dump --structure-tables-list=cache,cache_*,history,search_*,sessions" > "$sql_file" | ||
ddev import-db --file="$sql_file" | ||
rm "$sql_file" | ||
{ set +x; } 2>/dev/null | ||
|
||
display_status_message "Sync complete!" |