Workflow using Drush

Last updated on
10 January 2024

This page assumes you are familiar with using Drush, and that you have the latest version.

The following example shows how to export changes from development to production sites. The reverse is also possible.

If you don't have the environments already set up you should first create at least a Live and a Development environment:

  • Install a supported version of Drupal 9 or higher. We will call this site "Live."
  • Make a copy of this site (We'll call this "Development"). Make the copy by using the same source code, the files directory and a database dump of the Live site imported on Development. It is also possible now to install a fresh site from existing configuration, so copying the site is as easy as installing a new site with the configuration exported (see #1613424: [META] Allow a site to be installed from existing configuration) and you won't need a full copy of the site.
  • On the Development site, change the site name in admin/config/system/site-information to differentiate them.

The workflow to move the configurations from development to live with drush will be as follows:

  1. Run drush config:export in your Development site (older versions of Drush may use drush config-export instead) or just use the alias drush cex for short and it will work on all drush versions. This exports the configuration to your sync directory. The current contents of your sync directory will be deleted.

  2. Copy the content of the Development sync folder to the Live site's sync folder with a tool like rsync, Git, FTP or SCP.

  3. Run drush config:import in your Live site (older versions of Drush may use drush config-import instead) or use the alias drush cim.

  4. Drush will display the available configuration changes and prompt you with "Import the listed configuration changes? (y/n): ". Type "y" to confirm.

You may want to change the location of the sync directory.

Help improve this page

Page status: No known problems

You can: