When I back up the files for a Drupal 8 site, which directories in the following list should be included?

  • core
  • modules
  • profiles
  • themes
  • sites/default/
  • Any directory matching sites/default/files/config_*
  • sites/default/files/css
  • sites/default/files/js
  • sites/default/files/php
  • sites/default/files/styles
  • sites/default/files/field
  • vendor
  • I recently installed Drupal 8.3.0 with Acquia DevDesktop. After setting up the site, it notified me to update to 8.3.1. I did so, and found out that I accidentally deleted some pertinent config/settings file, because my site wanted to do the install routine. This is after making the codebase a git repo using the example .gitignore. I would really like to know what files I should make sure I maintain.
    – user1359
    Apr 19, 2017 at 20:48
  • Sounds like Acquia DevDesktop overwrote your codebase, killing your sites/default/settings.php file which made Drupal think the site wasn't installed yet.
    – Kevin
    Apr 19, 2017 at 20:52
  • @Kevin I did the update manually in git-bash.
    – user1359
    Apr 19, 2017 at 20:53
  • Oh okay... settings.php was likely ignored by git, and you may have accidentally deleted it. It happens. What you can do is look in git and jump back to a known version that still has the file, and pick it out.
    – Kevin
    Apr 19, 2017 at 20:54
  • @Kevin I downloaded Drupal core 8.3.1 through the browser via the download link at /admin/reports/updates. I moved the tar.gz file into my sites/ directory, ran tar -xvf -- actually, looking at your latest comment, it seems you may no longer be interested in the rest of this comment.
    – user1359
    Apr 19, 2017 at 20:56

1 Answer 1


The key directories are modules, themes, and profiles. You also want to backup all settings.php files, and uploaded files as well. Although, I would separate the two into two backup files, since, depending on the site, the uploaded files directory could be in the low MBs or hundreds to even GB of files. Give them both a readable date timestamp for a filename.

Also, backup your composer.json and composer.lock files. If you control your site build using Drupal Project or Acquia BLT which has a composer driven approach, composer.json will contain the information needed to rebuild your site (this does not include data, only code). Then it's just a matter of backing up custom modules and custom themes, since composer can fetch all the code and rebuild core.

  • I "might" want to backup settings.php files? How many are there, and where? Do I really want to back them up, or not? I am offering a bounty on a "detailed, canonical answer" here.
    – user1359
    Apr 19, 2017 at 20:59
  • 1
    It depends, some projects have one, some projects have multiple. Your sites directory can contain many site folders that point to different databases, constituting many settings.php files. If you are running one site, you likely only have one settings.php file. I would back up the entire sites directory, sans uploaded files (i.e. sites/default/files).
    – Kevin
    Apr 19, 2017 at 21:00
  • In what situations might I not want to backup any of the settings.php files?
    – user1359
    Apr 19, 2017 at 21:04
  • @user1359 Any situation where having backups of one or more of those files wouldn't be beneficial, really. E.g. you use Pantheon and have nothing in them except database credentials for your local environment. Might be no point backing up root/root user/pass combinations. As projects/environments get more complicated there could be any number of reasons why you don't want or need to back up a particular settings file. But unless there's a pressing reason to exclude (only you'll know that as they contain your settings data), some would say to back them up anyway "just in case". Can't hurt
    – Clive
    Apr 19, 2017 at 22:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.