Content Hub Tip #28: Export Content Hub configuration by CLI

Content Hub Tips logo

In the past, I've written several times about the Content Hub CLI. For me, this is a very important tool to help me synchronize my configuration across multiple environments. I've shown this during my presentation at the Sitecore Symposium of 2022. During the talk, I mentioned that it's possible to extract your Content Hub configuration easily.

You can start exporting via the CLI with the following command:
ch-cli system export

When you execute the command, you'll get the following image result below. 

Content Hub CLI Command propmpt

As you can see, the --type is a required option with the export command. With the option command, you can specify which types you want to export. If you limit the number of types you need to export, you also limit the resources that are being used to generate the export package. It also saves bandwidth when downloading the package from Content Hub.

To include multiple types in the command, you need to add multiple type options. For example:

--type MediaProcessing  --type Scripts --type Triggers

If you have multiple Content Hub instances configured within the CLI, you can specify which instance you would like to target via the --endpoint parameter. If you don't specify one directly, it will default to the active endpoint. You can check your active endpoint, by running the following command:

ch-cli endpoint list

The endpoint name with the * asterisks in front of it is the active endpoint.

Another cool feature of the CLI. is that you can wait for the job to be finished, but also for the order id of the package to be downloaded. With this order id you query the Content Hub and download the export file easily.

That said, do check out the CLI tooling. It has much more to offer than just importing and exporting features.

Until next time!