Acquia Copilot is a conversational AI connected into our product documentation and knowledge base. Ask Copilot about product features, technical details, troubleshooting and how to get started with Acquia products.
The instructions in this section do not apply to environments running on Cloud Next technologies. Use Acquia CLI, the Cloud Platform user interface, or Cloud Platform API v2 to download database backups on Cloud Next environments.
An environment’s Databases page in the Cloud Platform interface lists recent database backups for the environment. You can also use SSH and command line tools to confirm which database backups exist and download them directly from your environment, if desired.
Acquia recommends using command line tools to download backups if they are large (over 1 GB), since large downloads over HTTPS from the Cloud Platform interface may not complete successfully.
Required permissions
To run commands on a Cloud Platform environment, you must have the necessary permission. For non-production environments (dev or stage), you must have the Add SSH key to non-production environments permission. For production environments (prod), you must have the Add SSH key to production environments permission. By default, administrators and users with the Team Lead or Senior Developer roles have these permissions and users with the Developer role do not. For more information, see Working with roles and permissions.
Viewing available backups
To view which backups are actually available on an environment:
Production environment: /mnt/files/[sitename].prod/backups
If you want to view backups for the Development environment, use a command similar to the following:
cd /mnt/files/clouddocs.dev/backups
Run the ls command to determine which backup files are present.
You can download the backup files you want using command line tools.
Downloading backups with command line tools
The following is a set of examples for downloading database backups with several command-line tools. Be sure to either replace or set the following variables in the examples:
To download all your backups at once, replace yourdatabase-date.sql.gz with an asterisk (*). You can also use SFTP in the interactive mode by omitting everything after hosting.acquia.com.
The -i flag tells SFTP to use a specific key. Other useful flags are -b (batch mode) and -v (verbose, used for debugging issues).
SCP
To download with SCP, use a command similar to the following:
The -r flag recursively copies the specified directory if you’re using this command to copy files from your docroot. For example, this command will copy everything in subdirectories as well. Depending on your version of SCP, this may include symbolic links, so use caution if there are symbolic links to your files directories in the directory tree where you’re using -r.
rsync
To download with rsync, use a command like the following:
The -a flag uses archive mode, which is a series of options under one flag that attempt to preserve exactly as possible the file structures being transferred. This includes copying symlinks as symlinks, copying directories recursively, and preserving the owner:group settings on files and directories. The -v flag provides verbose output, useful in debugging or just keeping track of progress, and -z compresses files during data transfer. The -e"ssh-i${KEY}" part tells rsync to use SSH to pass key information. There are other options that can be passed in the -e flag that can be useful for synchronizing data, such as --ignore-existing (do not update files that already exist on the receiving end) and --delete (delete files from the destination directory that do not exist in the source directory).
Important
A full list of options is available, but be careful to practice on non-essential data, especially if using any of the synchronization or delete options.
Restoring backups from the command line
To restore the database in a Cloud Platform environment from a backup file:
Ensure that your database backup is unzipped and that it is in .sql format.
Drop your existing database, using the drush sql-drop command:
drush @[site].[env] sql-drop [--uri=my.site.com]
where:
[site] is the name of your application on Cloud Platform.
[env] is the environment into which you’re importing your database. Acceptable values are dev (Development), test (Staging), and prod (Production).
[db_name] is the name of your database. Use the database name shown on the Databases page for the environment, not an environment-specific name. For example, if your site name is example, your default database name will probably be example, and you should use that rather than an environment-specific name like exampledev or exampletest.
Run the following ah-db-import Drush command to restore your backup:
Downloading database backups from the command line
Note
The instructions in this section do not apply to environments running on Cloud Next technologies. Use Acquia CLI, the Cloud Platform user interface, or Cloud Platform API v2 to download database backups on Cloud Next environments.
An environment’s Databases page in the Cloud Platform interface lists recent database backups for the environment. You can also use SSH and command line tools to confirm which database backups exist and download them directly from your environment, if desired.
Acquia recommends using command line tools to download backups if they are large (over 1 GB), since large downloads over HTTPS from the Cloud Platform interface may not complete successfully.
Required permissions
To run commands on a Cloud Platform environment, you must have the necessary permission. For non-production environments (dev or stage), you must have the Add SSH key to non-production environments permission. For production environments (prod), you must have the Add SSH key to production environments permission. By default, administrators and users with the Team Lead or Senior Developer roles have these permissions and users with the Developer role do not. For more information, see Working with roles and permissions.
Viewing available backups
To view which backups are actually available on an environment:
Production environment: /mnt/files/[sitename].prod/backups
If you want to view backups for the Development environment, use a command similar to the following:
cd /mnt/files/clouddocs.dev/backups
Run the ls command to determine which backup files are present.
You can download the backup files you want using command line tools.
Downloading backups with command line tools
The following is a set of examples for downloading database backups with several command-line tools. Be sure to either replace or set the following variables in the examples:
To download all your backups at once, replace yourdatabase-date.sql.gz with an asterisk (*). You can also use SFTP in the interactive mode by omitting everything after hosting.acquia.com.
The -i flag tells SFTP to use a specific key. Other useful flags are -b (batch mode) and -v (verbose, used for debugging issues).
SCP
To download with SCP, use a command similar to the following:
The -r flag recursively copies the specified directory if you’re using this command to copy files from your docroot. For example, this command will copy everything in subdirectories as well. Depending on your version of SCP, this may include symbolic links, so use caution if there are symbolic links to your files directories in the directory tree where you’re using -r.
rsync
To download with rsync, use a command like the following:
The -a flag uses archive mode, which is a series of options under one flag that attempt to preserve exactly as possible the file structures being transferred. This includes copying symlinks as symlinks, copying directories recursively, and preserving the owner:group settings on files and directories. The -v flag provides verbose output, useful in debugging or just keeping track of progress, and -z compresses files during data transfer. The -e"ssh-i${KEY}" part tells rsync to use SSH to pass key information. There are other options that can be passed in the -e flag that can be useful for synchronizing data, such as --ignore-existing (do not update files that already exist on the receiving end) and --delete (delete files from the destination directory that do not exist in the source directory).
Important
A full list of options is available, but be careful to practice on non-essential data, especially if using any of the synchronization or delete options.
Restoring backups from the command line
To restore the database in a Cloud Platform environment from a backup file:
Ensure that your database backup is unzipped and that it is in .sql format.
Drop your existing database, using the drush sql-drop command:
drush @[site].[env] sql-drop [--uri=my.site.com]
where:
[site] is the name of your application on Cloud Platform.
[env] is the environment into which you’re importing your database. Acceptable values are dev (Development), test (Staging), and prod (Production).
[db_name] is the name of your database. Use the database name shown on the Databases page for the environment, not an environment-specific name. For example, if your site name is example, your default database name will probably be example, and you should use that rather than an environment-specific name like exampledev or exampletest.
Run the following ah-db-import Drush command to restore your backup: