64

I have this error when I try to import the config of an another site:

The staged configuration cannot be imported, because it originates from a different site than this site. You can only synchronize configuration between cloned instances of this site.

I have 10 customers, and I need to sync my site configuration with 10 different websites.
The site UUID is a problem for sharing a configuration with a different website. Is there a solution?

3
  • 1
    Another nice answer here drupal.stackexchange.com/q/152584/39617 Apr 25 '16 at 20:58
  • One way to do it is to import the config as part of a clean install. You can select the config as a profile similar to default or minimal.
    – Daniel
    2 days ago
  • One way to do this is to add $settings['config_sync_directory'] = '../config/sync'; in your settings somewhere.
    – Daniel
    2 days ago
14

Using Drupal Console

You can override your current site's UUID with the value present in the configuration you want to import.

You can achieve this with Drupal Console by overriding the uuid key for system.site.

drupal config:override

Then enter system.site for the configuration name, uuid for the configuration, and the UUID value, when prompted for each of them.

0
90

Youu can get the UUID with drush config-get "system.site" uuid.
You can change it with drush config-set "system.site" uuid [uuid].

4
  • I needed to create a dev environment for a site that I have no access to the server. I found the uuid in the configuration export file. It is in the file system.site.yml.
    – ndvo
    Apr 3 '20 at 17:11
  • 4
    And then before finally drush -y cim you may additionally drush -y entity:delete shortcut_set when running into The import failed due to the following reasons: Entities exist of type <em class="placeholder">Shortcut link</em> and <em c lass="placeholder">Shortcut set</em> <em class="placeholder">Default</em>. These entities need to be deleted before importing.
    – leymannx
    May 5 '20 at 13:40
  • If you need a uuid without the keys as I do for scripting: drush config-get "system.site" uuid --format
    – Thony
    May 6 '20 at 15:46
  • My site uuid is null :|. Don't know how that's possible... Sep 3 at 11:56
21

The Configuration Management only allow sync configuration between same site or project to avoid issues importing configuration from site a.com to b.com, to accomplish this validation Drupal 8 generate a UUID for each site.

You cat get your current site UUID executing the following command:

drush cget system.site

The command above we will have a similar output to next listing:

uuid: 236fa77c-d83e-42de-8a03-03c574c00160
name: Drupal 8
mail: user@example.com
slogan: ''
page:
  403: ''
  404: ''
  front: node
admin_compact_mode: false
weight_select_max: 100
langcode: en

The config import has a different UUID, you can confirm the UUID with the following command

cat sites/default/config/staging/system.site.yml

For that reason you need to change the value of Site UUID using the following Drush command:

drush cedit system.site

The command above enable you to use your favorite text editor to set the same UUID present in staging config files.

cat sites/default/config/staging/system.site.yml

After change the UUID and change the permissions, if you visit again the page example.com/admin/config/development/configuration you will see all changes, deletions, renames, and additions.

source: http://enzolutions.com/articles/2014/08/27/understanding-configuration-management-in-drupal-8/

5
  • 10
    Correct, but keep in mind that changing the site UUID without changing any others means that drupal will treat every field/node type/view/... that has a different UUID as a different thing and will first delete the old and then re-create it again, which will essentially delete all your content.
    – Berdir
    Mar 5 '15 at 15:47
  • Ok thank you, but it's not user-friendly for a user without a dedicated server and linux knowledge, a solution exist for basic/beginner users (without ssh and command lines, only a ftp server) please ? Drush need command lines and it's not user-friendly for my customers. Mar 7 '15 at 12:56
  • What's happen exactly if I change the site UUID of an existing Drupal website (fresh install) to match the exported configuration (with drush config-set system.site uuid "abcdef-...") ?
    – GiDo
    Sep 15 '15 at 16:19
  • 1
    One-line command to copy update site UUID. drush -y cset system.site uuid $(cat /path/to/config/system.site.yml | awk '/uuid/ { print $2 }')
    – ya.teck
    Aug 29 '17 at 10:14
  • if use have any problem using drush, kindly use devel module to get the current site UUID, \Drupal::config('system.site')->set('uuid', $this->siteUuid)->save(); Jan 8 '20 at 9:02
11

You can get the site UUID without access to the site or database.

If you don't have access to the original site/database, you can still sync from provided config files. The config will contain your site's UUID, so you need to set that first.

  1. Find your config/sync directory: If it's moved, you can find where it was set in settings.php. Look for: $config_directories['sync'], which will list the path.

  2. Go to that config path, and look for the file: system.site.yml In that file, look for uuid: 86b376c5-385e-4d13-bf00-e5e5443540e3 (you will have a different value, obviously). Copy that value.

  3. In drush, set your site to the same site uuid that we just discovered: drush cset system.site uuid 86b376c5-385e-4d13-bf00-e5e5443540e3

  4. Sync the config using drush drush cim -y

  5. If you get errors, read them. I had:

    • a missing module (which I had to download and enable)
    • content from the shortcuts module, which I had to delete first, at:
    • admin > config > User Interfact > Shortcuts

Once I did that, I reran the cim, and everything worked like a charm!

I had installed a local D8 instance before trying to restore from the provided config.

0
6

You can change the UUID for the destination site using drush cset and drush cget.

First get the source UUID:

$ cd ~/Sites/sourcesite <-- your drupal site root
$ drush cget system.site uuid
This will return something like:
'system.site:uuid': 86b376c5-385e-4d13-bf00-e5e5443540e3 

Replace the destination UUID

cd ~/Sites/destinationsite <-- your drupal site root
$ drush cset system.site uuid 86b376c5-385e-4d13-bf00-e5e5443540e3 

Now you can:

  1. Navigate to the destination site in your browser at admin/config/development/configuration/full/import
  2. select the configuration archive and select upload
  3. You will see a list of all the configuration items
  4. Scroll down to the bottom and click the import all button
1

How to automate the setting of the system.site uuid before config import

For people getting tired of doing this all over again. I finally got a fix on how to do this automatically. You would have to add a pre-command for config:import with drush to set the uuid. Read all about it here: https://stefvanlooveren.me/blog/fixing-systemsite-uuid-config-import-problem-drupal-8

1
  • tryed that but get an class Drupal not found error. 'Error: Uncaught Error: Class 'Drupal' not found in /var/www/html/drush/Commands/CustomCommands.php:12 Fürther I can see a new command drush set:uuid which isn't called befor the drush cim
    – macbert
    Apr 24 '20 at 16:54
0

If you follow the instructions in Gucho Ca's answer, and still have the problem, be sure to check that you have write permissions in your sync config directory. It will give you this same error message, even if your uuids are the same, but your sytem doesn't have write permissions.

A good way to check is to click on the Import Tab of the Synchronize section. If you don't have the correct file permissions it will tell you there.

0

The Above answers used to work for me until Drupal 9.2.3, but they are no longer working on Drupal 9.2.4 and Drush 10.6.0.

I was able to fix this issue by applying the patch given in "Site UUID in source storage does not match the target storage." when importing a config with empty system.site UUID.

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.