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:
Connect to your infrastructure using SSH. For example, you can use a command similar to the following:
Change directory to the
/backups
directory for the environment.- Development environment:
/mnt/files/[sitename].dev/backups
- Staging environment:
/mnt/files/[sitename].test/backups
- 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
- Development environment:
- 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:
sitename
: Your application’s sitename.env
- The Cloud Platform environment. For most applications, one ofprod
(Production),test
(Staging), ordev
(Development).server
: Your server name, which you can find on the Infrastructure page. For example,ded-123
.
You can use any GUI tool that supports these protocols, such as Fetch or WinSCP.
SFTP
To download with SFTP, use a command like the following:
sftp [sitename].env]@[server].prod.hosting.acquia.com:/mnt/files/[sitename]/backups/yourdatabase-date.sql.gz /path/to/your/backup/folder
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:
scp -r [sitename].[env]@[server].prod.hosting.acquia.com:/mnt/files/[sitename]/backups/ /path/to/your/backup/folder
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:
rsync -avz -e "ssh -i ${KEY}" [sitename].[env]@[server].prod.hosting.acquia.com:/mnt/files/sitename/backups/ /path/to/your/backup/folder
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).
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 aredev
(Development),test
(Staging), andprod
(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 isexample
, your default database name will probably beexample
, and you should use that rather than an environment-specific name likeexampledev
orexampletest
.
Run the following ah-db-import Drush command to restore your backup:
drush @[site].[env] ah-db-import /path/to/backup/file
After your database has been restored, Cloud Platform displays the following message:
Imported into database successfully
For information about database backup locations, see Downloading backups from the command line.