You are here

acquia-cloud-site-factory-post-db.sh in Acquia Cloud Site Factory Connector 8

#!/bin/sh
#
# Cloud Hook: post-db-copy
#
# The post-db-copy hook is run whenever you use the Workflow page to copy a
# database from one environment to another. (Note this means it is run when
# staging a site but not when duplicating a site, because the latter happens on
# the same environment.) See ../README.md for details.
#
# Usage: post-db-copy site target-env db-role source-env

site="$1"
target_env="$2"
db_role="$3"
source_env="$4"

# You need the URI of the site factory website in order for drush to target that
# site. Without it, the drush command will fail. The uri.php file below will
# locate the URI based on the site, environment and db role arguments.
uri=`/usr/bin/env php /mnt/www/html/$site.$target_env/hooks/acquia/uri.php $site $target_env $db_role`

# Print a statement to the cloud log.
echo "$site.$target_env: Received copy of database from $uri ($source_env environment)."

# The websites' document root can be derived from the site/env:
docroot="/var/www/html/$site.$target_env/docroot"

# Acquia recommends the following two practices:
# 1. Hardcode the drush version.
# 2. When running drush, provide the docroot + url, rather than relying on
#    aliases. This can prevent some hard to trace problems.
DRUSH_CMD="drush8 --root=$docroot --uri=https://$uri"

# Retrieve the site name.
$DRUSH_CMD cget system.site name

File

acsf_init/lib/cloud_hooks/samples/acquia-cloud-site-factory-post-db.sh
View source
  1. #!/bin/sh
  2. #
  3. # Cloud Hook: post-db-copy
  4. #
  5. # The post-db-copy hook is run whenever you use the Workflow page to copy a
  6. # database from one environment to another. (Note this means it is run when
  7. # staging a site but not when duplicating a site, because the latter happens on
  8. # the same environment.) See ../README.md for details.
  9. #
  10. # Usage: post-db-copy site target-env db-role source-env
  11. site="$1"
  12. target_env="$2"
  13. db_role="$3"
  14. source_env="$4"
  15. # You need the URI of the site factory website in order for drush to target that
  16. # site. Without it, the drush command will fail. The uri.php file below will
  17. # locate the URI based on the site, environment and db role arguments.
  18. uri=`/usr/bin/env php /mnt/www/html/$site.$target_env/hooks/acquia/uri.php $site $target_env $db_role`
  19. # Print a statement to the cloud log.
  20. echo "$site.$target_env: Received copy of database from $uri ($source_env environment)."
  21. # The websites' document root can be derived from the site/env:
  22. docroot="/var/www/html/$site.$target_env/docroot"
  23. # Acquia recommends the following two practices:
  24. # 1. Hardcode the drush version.
  25. # 2. When running drush, provide the docroot + url, rather than relying on
  26. # aliases. This can prevent some hard to trace problems.
  27. DRUSH_CMD="drush8 --root=$docroot --uri=https://$uri"
  28. # Retrieve the site name.
  29. $DRUSH_CMD cget system.site name