cs-icon.svg

Export Content Using the CLI

To migrate content from one stack to another, begin by exporting content from the source stack, then import it into the destination stack.

This guide explains how to use the cm:stacks:export command by logging in to CLI (or with a management token), using configuration files or direct CLI parameters.

Prerequisites

Supported Modules

Commands

The cm:stacks:export command lets you export content from one stack to another.

Usage

csdx cm:stacks:export -k <<stack_ApiKey>> -d <<file_path>>

Options

Use the following options with any applicable export command:

  • -k, --stack-api-key=stack-api-key: API key of the source stack.
  • -a, --alias: Management token alias of the source stack.
  • -d, --data-dir=data-dir: Absolute path to the folder to store the exported content.
    Example: -d "C:\Users\Name\Desktop\cli\content".
    If using branches, include the branch folder in the path: -d "C:\Users\Name\Desktop\cli\content\branch_name"
  • --branch=branch: [default: main] Name of the branch where you want to export content.
  • --module=module: (optional) Export a specific module from the source stack. If not specified, all modules are exported.
    Available modules: assets, content-types, entries, environments, stacks, extensions, marketplace-apps, global-fields, labels, locales, webhooks, workflows, custom-roles, taxonomies, personalize.
  • --content-types=content-types: (optional) The UID of the content type(s) whose content you want to export. In case of multiple content types, specify the IDs separated by spaces.
  • --secured-assets: [optional] Use this flag to export your content, if the secured assets feature is enabled for your stack.
  • -y, --yes: Force override all Marketplace prompts.
  • -c, --config=config: Path to the configuration JSON file containing all the options for a single run.

Note:

  • If the --yes flag is not passed, you are prompted to enter an encryption key while exporting the Marketplace app for the app configurations.
  • Ensure to add the --secured-assets flag to avoid errors while exporting content for the stack where the secured assets feature is enabled.

Examples

  • To export all modules from a stack:
    csdx cm:stacks:export -d "C:\Users\Name\Desktop\cli\content" -k bltxxxxxx
  • To export all modules from a particular branch of your stack (For example: develop):
    csdx cm:stacks:export -d "C:\Users\Name\Desktop\cli\content" -k bltxxxxxx  --branch develop
  • To export only content types from a stack:
    csdx cm:stacks:export -d "C:\Users\Name\Desktop\cli\content" --module content-types -k bltxxxxxx

Note: When exporting modules individually, follow this module sequence:
assets → environments → stacks → locales → extensions → marketplace-apps → webhooks → taxonomies → global-fields → content-types → workflows → entries → labels → custom-roles.
For example, before exporting entries, you must have already exported assets, environments, stacks, locales, extensions, marketplace-apps, webhooks, taxonomies, global-fields, content-types, and workflows.

Using Configuration File

You can also export content using a configuration file.

To get started, follow the steps below:

  1. Download the configuration file.
  2. Add your values.
  3. Note the path where the file is saved.

Usage

csdx cm:stacks:export -c <<config_file_path>>

Example:

  • To export content using a configuration file:
    csdx cm:stacks:export -c "C:\Users\Name\Desktop\cli\config.json"
Note:
  • Mac OS users must use "\" for paths in a JSON file.
  • Windows OS users must use "\\" for paths in a JSON file.

Configuration File Options

Following are the possible file options in the configuration file:

  • versioning: Export versioned entries. [options: true|false]
  • host: Set the host for export operation. [option: Any valid base URL from Content Management API]
  • preserveStackVersion: Preserve stack version while exporting the data. [options: true|false]
  • fetchConcurrency: Provide the number of files that must be fetched in one request. [option: Any natural number]
  • writeConcurrency: Provide the number of files that must be written in one request. [option: Any natural number]
  • source_stack: Provide the UID of the stack from which data must be exported. [option: <stack_uid>]
  • data: Provide the file path where the data must be stored. [option: <path-where-data-is-stored>]
  • branchName: Provide the name of the branch from which data must be exported. [option: <branch-name>]
  • moduleName: Specify the module name to be exported. [options: stack|assets|locales|environments|extensions|webhooks|global-fields|content-types|custom-roles|workflows|entries|labels|marketplace-apps]
  • securedAssets: Fetch only secured assets. [options: true|false]

Export Content Using Management Token

You can also export content from your stack using a management token.

Usage

csdx cm:stacks:export -a <<alias>>

Alternatively, refer to the following command to add several parameters or options in a single line:

csdx cm:stacks:export -a <<alias>> -d <<file_path>>

You can also export content by using a management token and a configuration file that contains the parameters or options and the associated values.

By doing so, you don’t need to separately provide parameters or options in the command.

Usage:

csdx cm:stacks:export -a <<alias>> -c <<config_file_path>>

Example:

  • To export content using a configuration file:
    csdx cm:stacks:export -a mytoken -c "C:\Users\Name\Desktop\cli\config.json"

Limitations

  • If multiple assets have the same UID and file name, only the first asset will be exported.
  • To resolve the maxContentLength and maxBodyLength errors, include these parameters in the configuration JSON with values specified in bytes. The default limit is 100 MB. For implementation details, refer to the example configuration file.
  • Currently, we export only the latest version of entries and assets.
  • Currently, the following modules cannot be exported:
Was this article helpful?
^