Export Content using CLI

If you want to migrate your content from one stack to another, first you need to export the content from the source stack and then import it into the destination stack.

You can export the following modules from a stack:

    Commands

    The cm:export command lets you export content from one stack to another. Let’s see how you can use this command in different ways.

    Export Content Using Management Token and Parameters

    Usage

    csdx cm:export -a <management_token_alias>

    You can add options/parameters to this command in a single line, as shown below:

    csdx cm:export -a <management_token_alias> -l <master_language_code> -d <file_path>

    Options

    • -a, --management-token-alias=management-token-alias: The management token of the source stack from which you will export content
    • -l, --master-lang=master-lang: The code of the source stack’s master language
    • -d, --data=data: The path or the location in your file system to store the exported content. For e.g., ./content
    • -m, --module=module: (optional) Specify a module to export to the source stack. If not specified, the export command will export all the modules to the stack. The available modules are assets, content-types, entries, environments, extensions, global-fields, labels, locales, and webhooks

      Note: When exporting modules individually, make sure you follow this module sequence: assets > environments > locales > extensions > webhooks > global-fields > content-types > entries > labels.  For example, before exporting entries, you must have had exported assets, environments, locales, extensions, webhooks, global-fields, and content-types.

    Export Content Using Management Token and Config file

    Usage

    csdx cm:export -a <management_token_alias> -c <config_file_path>

    Options

    • -a, --management-token-alias=management-token-alias: The management token of the source stack from which you will export content
    • -c, -config: The path of the configuration JSON file containing all the options for a single run. You can refer to an example config file here

    Export Content Using Auth Token and Parameters

    Usage

    csdx cm:export -A

    You can add options/parameters to this command in a single line, as shown below:

    csdx cm:export -A -s <stack_ApiKey> -l <master_language_code> -d <file_path>

    Options

    • -A, --auth-token: To use the auth token of the current session. It is automatically generated and stored in the session after running the login command.
    • -l, --master-lang=master-lang: The code of the source stack’s master language
    • -d, --data=data: The path or the location in your file system to store the exported content. For e.g., ./content
    • -s, --stack-uid-stack-uid: The API key of the source stack
    • -m, --module=module: (optional) Specify the module to export to the source stack. If not specified, the export command will export all the modules to the stack. The available modules are assets, content-types, entries, environments, extensions, global-fields, labels, locales, and webhooks.

      Note: When exporting  modules individually, make sure you follow this module sequence: assets > locales > environments > extensions > webhooks > global-fields > content-types > entries > labels.  For example, before exporting entries, you must have had exported assets, environments, locales, extensions, webhooks, global-fields, and content-types.

    Export Content Using Auth Token and Config file

    Usage

    csdx cm:export -A -c <config_file_path>

    Options

    • -A, --auth-token: To use the auth token of the current session. It is automatically generated and stored in the session after running the login command.
    • -c, -config: The path of the configuration JSON file containing all the options for a single run. You can refer to an example config file here.

    Limitations

    • For assets, exporting two or more assets having the same UID and file name, then only the first asset in the queue will get exported.
    • Currently, you cannot export content from the following modules:

    Next Steps

    Now that you have exported the content, the next step is to import the content into the stack.

    Was this article helpful?

    Thanks for your feedbackSmile-icon

    On This Page

    ^