Other examples¶
The following are examples of other operations that you can perform with Acquia CLI:
Creating a new application with Acquia CLI¶
To create a new Drupal application with the acli new
command:
- Open Terminal on your local machine.
Run the acli new
command.
The system prompts you to choose a project template.
See the following example:
$ acli new
Acquia recommends most customers use acquia/drupal-recommended-project,
which includes useful utilities such as Acquia Connector.
acquia/drupal-minimal-project is the most minimal application that will
run on Cloud Platform.
Which starting project would you like to use?
[0] acquia/drupal-recommended-project
[1] acquia/drupal-minimal-project
> 1
Creating project. This may take a few minutes
Creating a "acquia/drupal-minimal-project" project at "./drupal"
...
New 💧Drupal project created in /tmp/drupal. 🎉
Hooking into Acquia CLI commands¶
To define a script that runs before, or after any Acquia CLI command, add the script to the root composer.json
file. Ensure that you follow the naming pattern (pre|post)-acli-(command name with dashes)
. For example, pre-acli-push-db
or post-acli-pull-files
. The script does not run if you name it incorrectly. See the following examples:
"scripts": {
"pre-acli-pull-db": [
"echo \"I'm pulling the database now!\""
],
"post-acli-pull-db": [
"echo \"I'm done pulling the database!\""
],
}
Creating a log¶
When an environment does not have any logs, the system returns the following error in response to the api:environments:log-download command:
{
"error": "not_found",
"message": "No apache-access log files found with environment ID <ENVIRONMENT-ID>"
}
To resolve this error, you must create a log by running the api:environments:log-create command.
To wait for the api:environments:log-create command to complete execution on a specific environment, use the app:task-wait command as follows:
acli app:task-wait "$(acli api:environments:log-create <ENVIRONMENT-ID> apache-error)"
To download a database from Cloud Platform with Acquia CLI commands, run the following command:
$ acli api:environments:database-backup-download environmentId databaseName backupId
{
"url": "https:\/\/xxxxdev.prod.acquia-sites.com\/AH_DOWNLOAD?t=1683209089&d=\/mnt\/gfs\/xxxx.dev\/backups\/on-demand\/backup-2017-09-13-17-05-xxxx-58998932.sql.gz&dev=67c35dd70axxx140e937df593c36cxxx54fa801d536b1e93203edxxx4392e8a",
"expires_at": "2023-05-04T14:14:49+00:00",
"_links": {
"self": {
"href": "https:\/\/cloud.acquia.com\/api\/environments\/xxxxx-5b0cc2df-xxxx-xxxx-xxxx-95373ba19d9f\/databases\/xxxx\/backups\/61415412\/actions\/download"
},
"parent": {
"href": "https:\/\/cloud.acquia.com\/api\/xxxx\/xxxxx-5b0cc2df-xxxx-xxxx-99db-95373ba19d9f\/databases\/xxxx\/backups\/61415412\/actions"
},
"notification": {
"href": "https:\/\/cloud.acquia.com\/api\/notifications\/3ef70574-xxxx-xxxx-xxxx-fbf897537b2e"
}
}
}
The command generates a downloadable link.
To download the database, use the curl
command:
$ curl -o xxxx.backup.sql.gz "$(acli api:environments:database-backup-download environmentId databaseName backupId | jq -r .url)"
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 675k 100 675k 0 0 1442k 0 --:--:-- --:--:-- --:--:-- 1459k
The command uses jq
to parse the JSON format. For more information about jq
, visit Acquia CLI examples.
To download the latest database, run the following:
acli pull:db applicationName.prod databaseName --no-import
Deleting Custom Solr 7 Config Sets with Acquia CLI¶
You cannot delete config sets through the Cloud Platform interface. However, you can delete them through the Cloud API. Run the following Acquia CLI commands:
$ acli api:applications:search:configuration-set-delete -help
Description:
Removes and deletes a specific search configuration set from an application.
Usage:
api:applications:search:configuration-set-delete <applicationUuid> <configurationSetId>
api:applications:search:configuration-set-delete da1c0a8e-ff69-45db-88fc-acd6d2affbb7 ABCDE-1234.12345ab6c7e8f90g12i1jk234l56mn78
api:applications:search:configuration-set-delete myapp ABCDE-1234.12345ab6c7e8f90g12i1jk234l56mn78
Arguments:
applicationUuid The entity's universally unique identifier. You may also use an application alias or omit the argument if you run the command in a linked directory.
configurationSetId An ID that uniquely identifies a configuration set.
Options:
-h, --help Display help for the given command. When no command is given display help for the list command
-q, --quiet Do not output any message
-V, --version Display this application version
--ansi|--no-ansi Force (or disable --no-ansi) ANSI output
-n, --no-interaction Do not ask any interactive question
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
To obtain the ID of the config set that you want to delete, run the following:
acli api:applications:search:configuration-set-list
If you do not have the UUID of your application, you can use the docroot of the application name or you can find the UUID with the following command:
acli api:applications:list
Checking the DNS for domains hosted on Cloud Platform using Acquia CLI¶
Use Acquia CLI to check where your DNS points for domains hosted on Cloud Platform. Run the following script to list each domain in your Cloud Platform environment, and then run a dig
command against each domain.
1. Update Acquia CLI to the latest stable version:
2. Copy and paste the following script after you replace ___site___
and ___env___
with the site name and the environment for your application, for example, docroot and env.
for domain in $(acli api:environments:domain-list ___site___.___env___ | grep hostname | cut -d '"' -f 4); do
echo $domain:;
dig $domain +short
echo ""
done