Elasticdump profile

Used to transfer and save ES index data

precondition

Elasticdump can be installed in two ways: NPM and Docker. This document only describes how to install Elasticdump. For details about how to install Docker, see the official documentation. 1. Download the Node. js installation package

Wget HTTP: / / https://nodejs.org/dist/v10.13.0/node-v10.13.0-linux-x64.tar.gzCopy the code

2. Decompress the Node. js installation package

The tar xf node - v10.13.0 - Linux - x64. Tar. GzCopy the code

3. Create a link

ln -s~ / node - v10.13.0 - Linux - x64 / bin/node/usr/bin/node ln-s~ / node - v10.13.0 - Linux - x64 / bin/NPM/usr/bin/NPMCopy the code

4. View the version number

node -v
npm -v
Copy the code

If the version is displayed properly, the NPM installation is complete.

Install elasticdump

Run the following command to install Elasticdump using NPM.

npm install elasticdump -g
Copy the code

Elasticdump usage method

This article describes how to export data to a file or import data from a file. However, elasticdump is not limited to either of these two methods. If you are interested in elasticdump, you can find more details on how to use elasticdump.

The elasticdump script directory is displayed

Run the Elasticdump script in local mode

cd/ root/node - v10.13.0 - Linux - x64 / lib/node_modules/elasticdump/binCopy the code

Method 1: Export index data as a file

Export a template:

Export index Mapping data./bin/elasticdump \ --input=http://es Instance IP:9200/index_name/index_type \ --output=/data/my_index_mapping.json \# store directory
  --type=mapping 
Export index data./bin/elasticdump \ --input=http://es Instance IP:9200/index_name/index_type \ --output=/data/my_index.json \ --type=dataCopy the code

Modify the corresponding template information and execute the script to export the data to the file directory specified by output.

Method 2: Import the index data file to the index

Importing a template:

# Mapping data import to index./bin/elasticdump \ --output=http://es instance IP:9200/index_name \ --input=/home/indexdata/roll_vote_mapping.json \# import data directory
  --type=mapping
# ES document data import to index./bin/elasticdump \ --output=http:///es instance IP:9200/index_name \ --input=/home/indexdata/roll_vote.json \ --type=dataCopy the code

To import the index data file to ES specified by output, modify the corresponding template information and execute the script.

Elaelasticdump expand

Official website address: Elaelasticdump provides the following features for exporting data from one index to another, and exporting data using Query DSL(ES Query syntax).