Information for: DEVELOPERS   PARTNERS

Automating with Cloud Hooks

The Acquia Cloud interface automates the most common tasks involved in developing a Drupal application: deploying code from a version control system, and migrating code, databases, and files across your development, staging, and production environments. Cloud Hooks are scripts in your code repository that Acquia Cloud executes on your behalf when a triggering action occurs. With Cloud Hooks, you can automate other tasks such as:

  • Performing Drupal database updates each time you develop new code.
  • Scrubbing your production database each time you copy the database to development or staging by removing customer emails or disabling production-only modules.
  • Running your test suite or an application performance test each time you deploy new code.

Installing Cloud Hooks

Your Cloud Hooks are located in your Acquia Cloud code repository. Each branch of your repository contains a docroot directory with your application’s source code. Cloud Hooks are in the hooks directory next to docroot, not inside of docroot.

You can find the Cloud Hooks directory structure, sample hook scripts, and documentation at To start using Cloud Hooks with your application, copy the current version of the Cloud Hooks repository on GitHub into your Acquia Cloud repository.

Using Git, you can copy the Cloud Hooks repository with the following commands:

cd /my/repo
curl -L -o hooks.tar.gz
tar xzf hooks.tar.gz
mv acquia-cloud-hooks-* hooks
git add hooks
git commit -m 'Import Cloud hooks directory and sample scripts.'
git push

Cloud Hooks must be executable

Hook scripts must have the Unix executable bit set, or Acquia Cloud cannot run them. Although scripts with the executable bit set when first added to your repository will retain the executable bit, you must run the following commands to set the executable bit for files already in your Git repository:

chmod a+x ./
git add ./
git commit -m 'Add executable bit to'
git push

Quick start

To see the power of Cloud Hooks in action, you can run the “Hello, Cloud!” script when deploying new code in your development environment after installing Cloud Hooks.


The following example assumes that your development environment is running the master branch.

  1. Install the script to run on code deployments to development.

    cd /my/repo
    git checkout master
    cp hooks/samples/ hooks/dev/post-code-deploy
    git commit -a 'Run the hello-world script on post-code-deploy to Dev.'
    git push
  2. Sign in to Acquia Cloud and select your application.

  3. In the Dev environment code section, click the code switch button and select the master branch. If your Dev environment is already running master, select any other tag, and then select master again.

  4. Click Continue.

  5. Click Switch to confirm the switch to the master branch.

  6. View the task log. After the code deployment task completes, click its Details link to see the hook’s output. The output will look like the following example:

    Updating to deploy master
    Deploying master on
    [05:28:33] Starting hook: post-code-deploy
    Executing: /var/www/html/
    s1 dev master master [email protected]:s1.git git (as [email protected])
    Hello, Cloud!
    [05:28:34] Finished hook: post-code-deploy

You can use the code switch button on the Environments page to restore your development environment back to a previously-deployed branch.

Cloud Hooks and Remote Administration

If you have an Acquia Cloud Enterprise application with a Remote Administration (RA) environment, Cloud Hooks in the RA environment may result in unexpected behaviors or task failures, which can cause the RA automated update process to fail. For more information, see Deploy hooks.

Going further with Cloud Hooks

Complete documentation for Cloud Hooks and the latest sample and community-contributed hook scripts are available at By browsing the GitHub repository, you can do the following:

  • Find and use the latest sample and community-contributed hook scripts.
  • Read the complete documentation on how to write your own custom hook scripts.
  • Contribute your own hook scripts so others can use them.

Check out the following blog posts to see how some Acquia Cloud users have taken advantage of the power of Cloud Hooks: