The Import Overwrite feature in Contentstack CLI facilitates seamless stack-to-stack migration by enabling updates to existing content and adding new entries for unmatched content during imports. This ensures that the import process continues smoothly, even if an imported module already exists in the target stack, effectively preventing import failures.
By providing the ability to overwrite content, this feature streamlines content migration and eliminates the need for manual adjustments, saving time and effort during the import process.
Supported Modules
Usage
csdx cm:stacks:import --replace-existing --backup-dir <backup-dir-path> -k <value> --data-dir <content-dir-path>Options
Follow the steps below to perform the overwrite operation on your target stack:
csdx cm:stacks:import --replace-existing --backup-dir <backup-dir-path> -k <value> --data-dir <content-dir-path>The Import Setup command is an enhancement to the Import Overwrite feature, designed to address the challenges of dependency handling during imports. Updating specific modules—such as entries—often requires importing all dependent modules (e.g., extensions, assets) first, making the process more complex and time-consuming.
To resolve this, Contentstack CLI introduces the cm:stacks:import-setup pre-command, which:
By using these mappers with the import command, users can perform targeted imports without importing all dependencies. This enhancement simplifies dependency handling, providing greater flexibility and efficiency when using the Import Overwrite feature.
The cm:stacks:import-setup command is designed to simplify the import process by creating necessary mappers and backups for selected modules.
Usage
cm:stacks:import-setup --module module-name1 module-name2 --data-dir <exported-content-dir> -k <target-stack-api-key> --branch <branch>Options
| Flag | Short Flag | Description |
|---|---|---|
| --stack-api-key | -k | API key of the target stack where the content will be imported. |
| --data-dir | - | The path or location in your file system where the content to be imported is stored. |
| --alias | -a | [Optional] Alias (name) of the management token for the destination stack. |
| --module | - | [Optional] Specify the module(s) to import into the target stack. Supported values: global-fields, content-types, entries |
| --branch | [Optional] Name of the branch where you want to import your content. | |
| --branch-alias | - | [Optional] Alias of the target stack branch where you want to import your content. |
| --config | -c | [optional] Path of the configuration JSON file. |
| --backup-dir | - | [optional] Backup directory name when using a specific module. |
| --import-webhook-status | - | (optional) Status of the import webhook (disable / current). |
| --yes | -y | [optional] Force override all Marketplace prompts. |
| --replace-existing | - | Replaces the existing module in the target stack. |
| --skip-existing | - | Skips the module exists warning messages. |
| --personalize-project-name | - | (optional) Unique name for the Personalize project. |
| --skip-audit | - | Skips the audit fix during an import operation. |
| --exclude-global-modules | - | Excludes branch-independent modules from the import operation. |
| --skip-assets-publish | - | Skips asset publishing during the import process. |
| --skip-entries-publish | - | Skips entry publishing during the import process. |
| --skip-taxonomy-publish | - | Skips taxonomy publishing during the import process. |
Examples
csdx cm:stacks:import-setup --module global-fields --data-dir <exported-content-dir> -k <target-stack-api-key>csdx cm:stacks:import --replace-existing --backup-dir <backup-dir-path-generated-by-import-setup> -k <value> --data-dir <content-dir-path> --module global-fieldscsdx cm:stacks:import-setup --module content-types --data-dir <exported-content-dir> -k <target-stack-api-key>csdx cm:stacks:import --replace-existing --backup-dir <backup-dir-path-generated-by-import-setup> -k <value> --data-dir <content-dir-path> --module content-typescsdx cm:stacks:import-setup --module global-fields content-types --data-dir <exported-content-dir> -k <target-stack-api-key>csdx cm:stacks:import --replace-existing --backup-dir <backup-dir-path-generated-by-import-setup> -k <value> --data-dir <content-dir-path> --module global-fieldscsdx cm:stacks:import --replace-existing --backup-dir <backup-dir-path-generated-by-import-setup> -k <value> --data-dir <content-dir-path> --module content-typescsdx cm:stacks:import-setup --module entries --data-dir <exported-content-dir> -k <target-stack-api-key>csdx cm:stacks:import --replace-existing --backup-dir <backup-dir-path-generated-by-import-setup> -k <value> --data-dir <content-dir-path> --module entriescsdx cm:stacks:import-setup --module content-types entries content-types --data-dir <exported-content-dir> -k <target-stack-api-key>csdx cm:stacks:import --replace-existing --backup-dir <backup-dir-path-generated-by-import-setup> -k <value> --data-dir <content-dir-path> --module content-typescsdx cm:stacks:import --replace-existing --backup-dir <backup-dir-path-generated-by-import-setup> -k <value> --data-dir <content-dir-path> --module entriesThe overwrite feature is a highly versatile tool designed to support various migration scenarios. It simplifies content management and updates while minimizing dependency issues. Here are the key migration use cases:
This flexibility enables users to adapt the CLI to specific migration requirements, improving efficiency and reducing manual effort.
Here are the primary limitations to consider when leveraging the overwrite feature, despite its significant simplification of the migration process: