Updated on June 16, 2022

As Drupal "relies" on a Configuration Management (CM) system, one of its cool improvements is restoring a Drupal site from an existing configuration instead of only a database dump. This means that you can do a brand new Drupal installation and replicate an existing configuration on your new fresh database!

If you are new to Drupal or you want to learn more about CM, how to start using it and some Tips and Tricks, I suggest you to first read my blog post about Using Configuration Management and Git in Drupal.

In the following lines, I'll explain how to install a Drupal site and import an existing configuration from an exported folder. All of this with a single Drush command.

Requirements

By default, when running a Drupal Install process, the only available option is to start a new site from an existing Installation Profile: "Standard". Well, let me introduce "Configuration Installer":

Configuration Installer is a contributed Installation Profile initially created by Alex Pott, that allows installing a new Drupal site while importing an existing configuration package at the same time. To install config_installer, just download it from the config_installer project page and then extract it on the "/profiles" folder, or just run the following Drush command:

drush dl config_installer

Installing from an existing Configuration

Once config_installer is ready, you can use the default Drupal Install UI to upload your compressed configuration files package, then define the Database location and credentials to later go ahead with the final Installation.

Alternatively, you can just run the following Drush command:

drush site-install config_installer config_installer_sync_configure_form.sync_directory=CONFIG_FOLDER --db-url=DB_LOCATION_AND_LOGIN_CREDENTIALS --yes

which on the following sample, would be:

drush site-install config_installer config_installer_sync_configure_form.sync_directory=config/site --db-url=mysql://root:@127.0.0.1:33067/new_d8_databasename --yes

Pretty cool, huh? It is amazing how simple it is to use.

Useful scenarios to use Config Installer

The following is a list of possible cases where, on a daily basis, config_installer can make our lives way better:

  • When replicating the site on a new dev environment.
  • When building a Docker image.
  • When deploying/launching a site.
  • On a "content migration" based workflow.
  • To test/diff/verify the status of a Database Dump.

Where to go now?

The advantages of Drupal are enormous and CM is definitely something we can learn a lot from. If you want to learn more about it, I'll leave a few read-worthy links below if you want to go deep into this topic:

Want to learn some Drupal from the Experts? We have lots of Drupal training courses!