Use Drupal’s Configuration Synchronisation module to sync from dev to production

In this article we will look at how to create a development copy of your Drupal 8 website and then use the Configuration Synchronisation module to sync changes from one site to the other.

Why do this?

We have all been there, you make a simple little change to your website and it breaks. If you only have one version of your site then you have to fix it quickly before your users have their experience ruined.

This module makes it easy to experiment with a local version of your website, and then export those experiments to your production site when you are ready to take them live.

The method

You have two (or more) versions of your website, one production site that your users see, and a development site where you can make changes and experiment without breaking things for your users.

  1. Make a change to your development site’s configuration (add a module, make a view etc)
  2. Export the configuration changes using the Configuration Synchronisation module
  3. Copy any files you may need such as new modules, CSS, JS files etc (more on this later)
  4. Paste the copied files into your production websites structure
  5. Import the configuration that you exported from Development

Creating the development site from your production site

The Drupal Configuration Synchronisation module only works on exact copies of a site, the site must have the same ID number (UUID) and the same or similar setup.

Do you intend for your development site to be stored on a local machine or with your web host? Your needs will dictate your setup. I will assume you have a local development site in this article.

You will need to:

  1. Install a web server such as Apache, along with PHP, MySQL
  2. Clone your Production site (files and database) to the local server
  3. Set up virtual hostname for your local site (optional)

Exporting and importing changes

The Configuration Synchronisation module will not sync all changes, only those made to the configuration.

It will include:

  • Whether a module is installed
  • Added or changed Views
  • Content types and fields

What this means is that if you add a new module to your development site, then export/import the configuration to your production site, you will get an error saying the new modules cannot be installed as they don’t exist. You will have to copy the module directory from your development site and add it to your modules directory of your production site.

The same is true for CSS files and actual site content too. If you make a design change using CSS, you will have to add the CSS file to the production site yourself.

The process will go like this:

  1. Add new modules/content types/views/css etc to your development site
  2. Export the configuration (can be the complete configuration for individual items)
  3. Copy over any new modules and file changes to your production site
  4. Import the configuration changes
  5. Flush the cache and run the update.php as required

Next steps

The above example explains the basics of how to sync, you could also consider the following:

  • Add more copies of your site. A copy which is on the same server as your production site can be used to test changes in a live environment without the risk of breaking your production site. You may also want a further local copy so you can experiment.
  • Git or other Version Control System. If you work with other people or simply want to keep a track of your changes, version control can make life easier.

 

 

 

Tags

Configuration Synchronisation
version control system

Add new comment

CAPTCHA
Answer the below question to help us fight spam

How many legs does an elephant have?