Score:0

Config Export changes to different folder

mw flag

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?

id flag
Perhaps https://www.drupal.org/project/config_partial_export can do so.
Andrew Morris avatar
mw flag
@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
Lambic avatar
ph flag
Have you considered using drush deploy instead of update hooks? drush deploy runs update hooks, then does a drush cim, then runs deploy hooks
Andrew Morris avatar
mw flag
@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'?
id flag
https://drupal.org/project/config_partial_export ships with a drush command.
Score:0
id flag

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

Andrew Morris avatar
mw flag
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');`
id flag
Allowing overriding that could be a feature request. But given that, my answer is not the answer.
Score:0
cn flag

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.

Andrew Morris avatar
mw flag
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
4uk4 avatar
cn flag
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.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.