6

Drupal 8 has this new configuration management tool at /admin/config/development/configuration. I have an experimental site running Drupal 8 beta14, and I want to import a few settings into my new beta15 site. I don't want to copy everything, I experimented with various things on the old site and only need a few things on the new one.

What I want to copy are content types, the fields in those content types as well as image styles. But looking at the export tool, it seems I can only export a single item at a time.

Is there a way to export all items of a specific group at once, e.g. all content types or all image styles? And for content types, is there a way to export all the fields as well together with the content type?

3

There are two different things you can do.

You can, as you found, export and import single objects.

Or, you can do a config sync. Which means everything and is usually used to import configuration changes from staging to production or similar.

So you can do a full config export, then all the files will be in your staging folder (not the same as a staging environment) and import them in a different site. Note that there are some limitations, for example, you always need to do a full import (so export the existing config of a site, update it with some changes, then import it again) and the sync only works if the UUID in system.site matches, as it is not supported to import from a separate installation. (But you can import a group of files that don't exist yet.. careful with the UUID's, as the same object with a different UUID is treated as a delete + create, not update).

So you need to pick the files you want to re-use and put them either into an existing export from the target site or put them in a config/install folder of a module, then it will be imported when that module is installed (and only then, there are no automated updates).

You can also look at the 8.x version of the Features project, which basically offers a UI to pick a number of configuration files, similar to what you might know from D7.

1

I don't think this is currently supported. The best candidate for that would be Drush, and its config-export command. But as you can see below, there's no indication that groups are supported.

$ drush config-export --help
Export config from the active directory.

Examples:
 drush config-export --skip-modules=devel  Export configuration; do not include the devel module in the exported configuration, 
                                           regardless of whether or not it is enabled in the site.

Arguments:
 label                                     A config directory label (i.e. a key in $config_directories array in settings.php). Defaults 
                                           to 'staging'

Options:
 --add                                     Run `git add -p` after exporting. This lets you choose which config changes to stage for      
                                           commit.                                                                                       
 --branch=<branchname>                     Make commit on provided working branch. Ignored if used without --commit or --push.           
 --commit                                  Run `git add -A` and `git commit` after exporting.  This commits everything that was exported 
                                           without prompting.                                                                            
 --destination                             An arbitrary directory that should receive the exported files. An alternative to label        
                                           argument                                                                                      
 --message                                 Commit comment for the exported configuration.  Optional; may only be used with --commit or   
                                           --push.                                                                                       
 --push                                    Run `git push` after committing.  Implies --commit.                                           
 --remote=<origin>                         The remote git branch to use to push changes.  Defaults to "origin".                          
 --skip-modules                            A list of modules to ignore during export (e.g. to avoid listing dev-only modules in exported 
                                           configuration).

Aliases: cex

My best bet at this point would be to file an issue against the Drush project so that you submit a feature request. I agree with you it'd make sense because currently it's pretty painful not to miss dependencies.

0

You can use Features module for grouping configurations which is not stable yet for D8 or checkout Drupal Console

Take a look at this answer: https://drupal.stackexchange.com/a/190242/23477

  • if the same answer fits two questions, please vote to close as possible duplicate. If it's only similar, then please post it directly, with needed alterations. – Mołot Feb 12 '16 at 13:07
0

I've written a Python script which exports a group of configuration items using drush. You can find the script on a related thread, here.

0

You can try Config partial export module which allows you to exports only the selected files from the list of modified config files. It is able to export to a tarball only modified configuration files. After export you can copy the files from the tarball to your config/install folder in order to add them to your install profile and apply those changes on next install.

The module adds Partial config tab to Configuration management. It also provides a new drush command (see: drush cpex --help for help).

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.