Backing up your Drupal file system

Backing up your Drupal website

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 server.

There are several methods that you can use to back up your Drupal website, including installing the Backup and Migrate module, copying files using an FTP client, or using command-line tools.

  • Using the Backup and Migrate module

    You can add the Backup and Migrate module to your website, which 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.

  • Copying files using an FTP 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 FTP:

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

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

  • Backing up your website using the command line

    You can also 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:

    • rsync

      Using rsync 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 command on the command line of your local computer, (not signed in to your remote webserver):

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

    • scp

      To make a backup of your website's files (located on a remote web server), use the scp command on the command line of your local computer, (not signed in to your remote webserver). 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

Backups using Drush

One way to get a full, compressed archive of a site is to use Drush. The drush archive-dump command can back up your code, files, and database into a single file. Use this command with caution, because Acquia can not guarantee performance on a production site if this is used.