0

Is it possible to export only the changed configuration files to a specified folder?

When you run drush cex to see the change list of files like this

+------------+----------------------+-----------+
| Collection | Config               | Operation |
+------------+----------------------+-----------+
|            | views.view.frontpage | Update    |
+------------+----------------------+-----------+

I'm trying to export updated configuration items into a specific folder so that I can get items to run from an update hook, so I need to export them somewhere other than the default config export location

Whilst doing it for a single config item isn't much trouble, it'll be a bit of a pain to move a huge list of changes to a folder

I thought that when you put the --destination flag on the drush cex command that it would export the differences to a new folder, but it does the whole lot again.

Is there a simple way to export only the changes to a directory?

5
  • Perhaps drupal.org/project/config_partial_export can do so.
    – cilefen
    Jun 9, 2023 at 15:30
  • @cilefen, I've installed that one and it's good for giving a list of the differences, but it gives the configuration as a zip, ideally I'm wanting to do this from a CLI Jun 9, 2023 at 15:32
  • Have you considered using drush deploy instead of update hooks? drush deploy runs update hooks, then does a drush cim, then runs deploy hooks
    – Lambic
    Jun 9, 2023 at 15:33
  • @Lambic well the current requirement is due to new hosting infrastructure requirements, so this is what we've been advised to, I'm just trying to figure out a method to help doing it, but wouldn't Drush have the same issue? Wouldn't I have to put my different config 'somewhere'? Jun 9, 2023 at 15:37
  • drupal.org/project/config_partial_export ships with a drush command.
    – cilefen
    Jun 9, 2023 at 15:37

2 Answers 2

0

Config Partial Export module supports this functionality and it has a Drush command.

2
  • The commands that CPEX offers seem to give you the ability to use wildcards against config names and to list out the differences, but the destination directory is referenced from the the Drupal setting - $destination_dir = Settings::get('config_sync_directory'); Jun 9, 2023 at 15:44
  • Allowing overriding that could be a feature request. But given that, my answer is not the answer.
    – cilefen
    Jun 9, 2023 at 16:06
0

I agree with @Lambic comment, it's not a good idea to mix update hooks and importing config. If you need more info about the changes copy the sync folder before drush cex and then run the command diff. You can use the result of diff to patch the destination. If you are only interested in the changed file names use the option --brief. Or use git for deployment which runs such things automatically.

2
  • Thanks, the only real reason I'm looking into this is kinda because my hand is being forced by the way our company needs to work with our new hosting provider, we are moving our setup to be part of a multisite and we've been advised to make any 'snowflake' sites (eg, completely unique ones) into custom made modules containing all their config etc, which is why I'm looking for a method to move changed configuration in bulk to a separate folder Jun 12, 2023 at 8:36
  • Do you mean by unique sites having different site UUIDs? You can put the drush cex output to the /config/install folder of the custom-made modules, although this is not intended for this use case, by removing the UUID and the config hash. You could write a shell script to automate this procedure.
    – 4uk4
    Jun 12, 2023 at 9:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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