Loading...


Related Products


Date Published: July 31, 2023

Backing up your Drupal file system

Issue

How do I backup my Drupal website's files?

It's important to regularly back up the complete file structure of your Drupal website, including the original Drupal distribution, any modules or themes that you may have added, and the uploaded files that Drupal manages.

All of these files are required if you want to restore your website in case of catastrophic failure, set up copies of your website for development, testing or upgrade staging, or move your website from one server to another.

Resolution

Note: For information about backing up your Acquia Cloud-hosted website's files, see Backing up your site.

ImportantBacking up your website's files does not also back up your website's database.To be able to completely restore your website from a backup, you must also separately back up your website's database.

Whatever backup method you choose, make a backup and restore your website in a test environment before relying on it as a backup strategy for a production website.

There are several methods you can use to back up your Drupal website, including:

SFTP client

Backing up your website can be as simple as copying all of your website's files back to your local computer for archival. To do this using SFTP:

For ongoing, regular backups, ensure that your SFTP client is configured to transfer only new or updated files, which can save both time and network bandwidth.

  1. On your computer, create an archive folder for your website's files.
  2. Open an SFTP connection to the remote server.
  3. Copy the contents of your website's docroot to the archive folder you created on your computer.

Command line

You can use a command-line tool to transfer your website's files from a remote server to your local computer for backup. Two of these tools (rsync and scp) and their use are described as follows:

Note: In each of the following command-line examples, replace the following values:

  • [username]@[example.com] are the login credentials that you use to connect to the remote server.
  • /path/to/[docroot] is the absolute path to your website's document root. You can also back up a specific directory, using something like staging-1234.prod.hosting.acquia.com:dev/sites/default/files to back up the files directory in your development environment.
  • /local/path is the path on your local computer to the archive folder.

Both rsync and scp commands should be run from the command line on your local computer, not from your remote webserver.

rsync

Using rsync, with the following flags, only transfers remote files that are new or updated since the last backup, saving time and bandwidth. 

To make a local backup of your website's files from a remote web server, use the following rsync:

rsync -avz -e ssh [username].[environment]@[example.com]:/path/to/[docroot] /local/path/

scp

The following scp command copies all of the files on your remote server to your local computer:

scp -r [username]@[example.com]:/path/to/[docroot] /local/path
 

Drush

Note: drush archive-dump has been deprecated in drush 9.

The drush archive-dump command can back up your code, files, and database into a single compressed archive file. Use this command with caution. Acquia can not guarantee performance on a production website if this is used.

Incremental external backups

An incremental external backup might be a better solution and have more features than a 1:1 backup.

There are several automated file backup services/tutorials:

Backup and Migrate module

Important note for Acquia Cloud users: If you host your website on Acquia Cloud you cannot use the Backup and Migrate module to back up your website. For more information about this issue, see Backup and Migrate module not supported on Acquia Cloud .

The Backup and Migrate module allows you to back up your website's files to both your local computer and to other offsite solutions. You can also use the module to migrate your website between environments. For more information about using the module, see the module's project page on drupal.org.

Did not find what you were looking for?

If this content did not answer your questions, try searching or contacting our support team for further assistance.

Back to Section navigation
Back to Site navigation