Was this article helpful?
Thanks for your feedback
In this section, we will cover how to migrate your content from one stack to another within Contentstack. To migrate content, you will need to use the “contentstack-export” and “contentstack-import” tools that are provided by Contentstack.
Warning: This document has been deprecated. We will soon stop supporting this approach. Check out our detailed documentation on how to migrate content (export and import content) between stacks within Contentstack using the command-line interface (CLI).
To migrate your content from one stack to another, you need to first export content from the source stack and then importing this exported content into the destination stack. To do so, you need to perform the steps given below:
Navigate to the root folder of the utility tool and run the command given below to install the node modules that are necessary for exporting the content into your file system:
npm install
Add configuration details
: If you are using this utility in the European region, you will have to make changes in the default.js file inside the config folder and the remaining steps remain the same.
So open default.js file and change:
host:'https://api.contentstack.io/v3', cdn: 'https://cdn.contentstack.io/v3',
To
host:'https://eu-api.contentstack.com/v3', cdn: 'https://eu-cdn.contentstack.com/v3',
Before exporting content, certain changes need to be made in the configuration file of the utility tool. So, open the “index.js” file within the “config” folder of the utility tool and add the following configuration details:
module.exports = { master_locale: { // master locale of the stack name: 'English - United States', code: 'en-us' }, // Credentials email: '', // (optional) password: '', // (optional) // Stack API KEY source_stack: '', // mandatory access_token: '', management_token: '', // Path where the exported data will be stored (relative path) data: './contents' };
Note: We have updated the configuration of the export script to support management token. So if you don't want to use your email and password, then providing management token is mandatory in the config, else you can keep this blank.
Here's a brief of what values you need to provide for the above configuration parameters:
: Enter the name and code of the
master localeof your stack in the parameters given below:
: Your Contentstack account password
Note: The email and password configuration parameters are mandatory only when exporting the webhook and label modules.
: The Access Token of the source stack from which you need to export your data
Note: We have stopped supporting Access Token for all stacks created after December 16, 2020. For stacks created after this release, the Access Token will no longer be generated.
Warning: You need to be careful when providing the “master_locale” value, because if while importing content the master locale of your stack differs, the migration procedure fails.
npm run export
This command will extract data of assets, environments, locales, contentTypes, entries. These files are stored in the path mentioned in the “data” key in the “index.js” file under the “config” folder.
npm run export-{module-name}
When exporting modules individually, make sure you follow the module sequence as given below, for example, before exporting entries, you must have had exported assets, environments, locales, extensions, webhooks, global fields, and content types:
Note: This utility tool can be used to extract only the latest published version of an entry.
The exported content is now ready to be imported into Contentstack. This content will be in JSON format and stored at the location provided in the “index.json” configuration file from where you can later import the data into Contentstack.
To import the content, follow the steps mentioned in the Import Content into Contentstack document.
Was this article helpful?
Thanks for your feedback