In Multi-Experience Operations, duplicate an existing site to create a new site with the same content and configuration. This method is the most efficient way to deploy new sites that share a common baseline in the same codebase. After you duplicate a site, Cloud Platform creates a new site entry and provisions it across the selected target environments using the data from a source environment.
You can duplicate a site either from the Sites list within a codebase or directly from a specific Environment Overview page.
To duplicate an existing site:
In Source environment, select the environment version of the site to duplicate.
If you used the Environment Overview in Step 3, this field is pre-selected.
Data replication By default, the system copies all content, configurations, and records from the source environment to all selected target environments.
Technical identifiers The technical identifier is permanent and helps with Secure Shell (SSH) keys and domain names. This identifier must be unique in the codebase. You cannot change the identifier after you create the site.
Entitlements Each duplicated site counts toward the total Multi-Experience Operations site entitlement. The Duplicate site button remains inactive if you reach the entitlement limit or if required fields are invalid.
Hook parameters Use the Duplicate parameter field to pass specific values to a cloud hook. You can use these values to delete sensitive data during the duplication process.
Duplication without cache rebuild execution can break the interface theme. To ensure that a duplicated site reflects the most recent data and configurations, you must clear or rebuild caches and then clear Varnish cache through the UI to complete the duplication process. To rebuild the cache, add a post-site-instance-duplicate script to the codebase.
The hook script triggers after the site instance is active and the corresponding file system and database are provisioned. For additional file system and database provisioning details, check the task logs on the customer codebase overview page.
To add the duplicate site hook:
Follow the general Cloud Hook pattern: This process follows the standard Acquia Cloud platform hook workflow. Ensure that the repository structure supports the /hooks directory at the root level.
Create the hook script: In the local codebase, create a new script file at the following path, hooks/common/post-site-instance-duplicate.
To execute post-site-instance-duplicate on specific MEO environments, use the following path, hooks/<environment name>/post-site-instance-duplicate.
Add the Drush command Add the cache-rebuild Drush command to ensure the new site is current.
Drush cc (Cache Clear): Use for Drupal 7 and earlier.
Drush cr (Cache Rebuild): Use for Drupal 8, 9, 10, and 11.
The following is an example of hook script:
#!/bin/bash
set -ev
# Factory Hook: post-site-instance-duplicate (simplified)
# Usage: post-site-instance-duplicate.sh [optional parameters]
echo $*
# Resolve runtime env from execution user; this is the environment where hook runs.
runtime_account="$(whoami)"
runtime_site=""
runtime_env=""
internal_subdomain="$3"
echo "Internal subdomain: $internal_subdomain"
if [[ "$runtime_account" == *.* ]]; then
runtime_site="${runtime_account%%.*}"
runtime_env="${runtime_account#*.}"
fi
if [[ -z "$runtime_site" || -z "$runtime_env" ]]; then
echo "Unable to resolve runtime site/environment from account: $runtime_account"
exit 1
fi
echo "Runtime sitegroup: $runtime_site"
echo "Runtime environment: $runtime_env"
destination_domain="${internal_subdomain-$runtime_site$runtime_env.gardens.acquia-sites.com}"
echo "Destination domain: $destination_domain"
# Drush executable:
drush="/mnt/www/html/$runtime_site.$runtime_env/vendor/bin/drush"
# Rebuild all caches (Drupal 8+ recommended)
$drush -r "/mnt/www/html/$runtime_site.$runtime_env/docroot" -l "$destination_domain" cache:rebuild
exit 0
Make the script executable: Run the following command to ensure Cloud Platform can execute the hook: .
Duplication without cache rebuild execution can break the UI theme; therefore, a cache rebuild is required. The script executes after the site instance is fully active. Use the Drush command-line tool within this script to automate post-duplication tasks, such as drush cache-rebuild, to ensure site consistency.
chmod +x hooks/common/post-site-instance-duplicateCommit and push the script: Add, commit, and push the script to the codebase repository. The hook triggers after the duplicated site is active.
git add.
git commit -m "Add post-site-instance-duplicate hook to clear caches"
git pushClear Varnish cache: Initiate the Varnish cache clear after duplication for the site instance is complete.
Navigate to the duplicated site instance from either Sites Overview or Environments Overview.
Select Clear caches from the Actions menu on the site instance. This action clears the Varnish cache. If Platform Content Delivery Network (CDN) is enabled, it also clears the CDN cache for all Cloud Platform domains associated with the site. This action does not trigger a Drupal cache clear.
If this content did not answer your questions, try searching or contacting our support team for further assistance.
chmod +x hooks/common/post-site-instance-duplicateCommit and push the script: Add, commit, and push the script to the codebase repository. The hook triggers after the duplicated site is active.
git add.
git commit -m "Add post-site-instance-duplicate hook to clear caches"
git pushClear Varnish cache: Initiate the Varnish cache clear after duplication for the site instance is complete.
Navigate to the duplicated site instance from either Sites Overview or Environments Overview.
Select Clear caches from the Actions menu on the site instance. This action clears the Varnish cache. If Platform Content Delivery Network (CDN) is enabled, it also clears the CDN cache for all Cloud Platform domains associated with the site. This action does not trigger a Drupal cache clear.
If this content did not answer your questions, try searching or contacting our support team for further assistance.