Import and Export data with contentful-cli
March 3, 2020Import and Export contentful data with below steps.
Step 1: installation
Local installation Using npm:
npm install -g contentful-cli
Step 2: contentful-cli
Type below command and you gonna see details as per below screenshot:
contentful
Step 3: login in contentful-cli
Type below command for login in contentful-cli
contentful login
Now login with the browser. Copy to clipboard and paste into the command line.
Now you have a successful login.
Step 4: space list
Now time to export the data from contentful so let's start.
you can see all the space list with below command
contentful space list
Now you can choose specific space which data you want to export or import. with below command
contentful space use
choose any one space
Step: 5 Export Data
After selecting space now type below command to export data
contentful space export
Now you can see contentful-cli generated some random name contentful-export.json files in the root directory with all Exported entities.
Yeah, its to easy right...
Step 6: Import Data
for importing your JSON file into contentful-cms you have to put contentful-data.json file in root directress with any name. for now, I have created contentful-data.json in the root so let's start.
before start importing the contentful-data.json data you have to first take a look in which space you want to import data with below command. you can change space from here also.
contentful space use
Import data contentful-data.json ( Local file ) to contentful with below command
contentful space import --content-file contentful-data.json
Step 7: Finish
Now you can check your contentful space and all the data which we have imported from JSON files.
If you want to learn more about contentful-cli check it out below link: