Public | Automated Build

Last pushed: a year ago
Short Description
Import and export tools for elasticsearch
Full Description


Tools for moving and saving indicies.

Version Warnings!

  • Version 1.0.0 of Elasticdump changes the format of the files created by the dump. Files created with version 0.x.x of this tool are likely not to work with versions going forward. To learn more about the breaking changes, vist the release notes for version 1.0.0. If you recive an "out of memory" error, this is probaly the cause.
  • Version 2.0.0 of Elasticdump removes the bulk options. These options were buggy, and differ between versions of Elasticsearch. If you need to export multiple indexes, look for the multielasticdump section of the tool.
  • Version 2.1.0 of Elasticdump moves from using scan/scroll (ES 1.x) to just scan (ES 2.x). This is a backwards-compatible change within Elasticsearch, but performance may suffer on Elasticsearch versions prior to 2.x.



npm install elasticdump


npm install elasticdump -g


Standard Install

elasticdump works by sending an input to an output. Both can be either an elasticsearch URL or a File.


  • format: {protocol}://{host}:{port}/{index}
  • example:


  • format: {FilePath}
  • example: /Users/evantahler/Desktop/dump.json


  • format: stdin / stdout
  • format: $

You can then do things like:

# Copy an index from production to staging with analyzer and mapping:
elasticdump \
  --input= \
  --output= \
elasticdump \
  --input= \
  --output= \
elasticdump \
  --input= \
  --output= \

# Backup index data to a file:
elasticdump \
  --input= \
  --output=/data/my_index_mapping.json \
elasticdump \
  --input= \
  --output=/data/my_index.json \

# Backup and index to a gzip using stdout:
elasticdump \
  --input= \
  --output=$ \
  | gzip > /data/my_index.json.gz

# Backup the results of a query to a file
elasticdump \
  --input= \
  --output=query.json \
  --searchBody '{"query":{"term":{"username": "admin"}}}'

Non-Standard Install

If Elasticsearch is not being served from the root directory the --input-index and
--output-index are required. If they are not provided, the additional sub-directories will
be parsed for index and type.


  • format: {protocol}://{host}:{port}/{sub}/{directory...}
  • example:
# Copy a single index from a elasticsearch:
elasticdump \
  --input= \
  --input-index=my_index \
  --output= \
  --output-index=my_index \

# Copy a single type:
elasticdump \
  --input= \
  --input-index=my_index/my_type \
  --output= \
  --output-index=my_index \

# Copy a single type:
elasticdump \
  --input= \
  --input-index=my_index/my_type \
  --output= \
  --output-index=my_index \

Docker install

If you prefer using docker to use elasticdump, you can download this project from docker hub :

docker pull taskrabbit/elasticsearch-dump

Then you can use it just by :

  • using docker run --rm -ti taskrabbit/elasticsearch-dump
  • remembering that you cannot use localhost or as you ES host ;)
  • you'll need to mount your file storage dir -v <your dumps dir>:<your mount point> to your docker container


# Copy an index from production to staging with mappings:
docker run --rm -ti taskrabbit/elasticsearch-dump \
  --input= \
  --output= \
docker run --rm -ti taskrabbit/elasticsearch-dump \
  --input= \
  --output= \


elasticdump: Import and export tools for elasticsearch
version: %%version%%

Usage: elasticdump --input SOURCE --output DESTINATION [OPTIONS]

                    Source location (required)
                    Source index and type
                    (default: all, example: index/type)
                    Destination location (required)
                    Destination index and type
                    (default: all, example: index/type)
                    How many objects to move in batch per operation
                    limit is approximate for file streams
                    (default: 100)
                    Display the elasticsearch commands being used
                    (default: false)
                    Suppress all messages except for errors
                    (default: false)
                    What are we exporting?
                    (default: data, options: [analyzer, data, mapping])
                    Delete documents one-by-one from the input as they are
                    moved.  Will not delete the source index
                    (default: false)
                    Preform a partial extract based on search results
                    (when ES is the input,
                    (default: '{"query": { "match_all": {} } }'))
                    Output only the json contained within the document _source
                    Normal: {"_index":"","_type":"","_id":"", "_source":{SOURCE}}
                    sourceOnly: {SOURCE}
                    (default: false)
                    Will continue the read/write loop on write error
                    (default: false)
                    Time the nodes will hold the requested search in order.
                    (default: 10m)
                    How many simultaneous HTTP requests can we process make?
                      5 [node <= v0.10.x] /
                      Infinity [node >= v0.11.x] )
                    Integer containing the number of milliseconds to wait for
                    a request to respond before aborting the request. Passed
                    directly to the request library. Mostly used when you don't
                    care too much if you lose some data when importing
                    but rather have speed.
                    Integer containing the number of rows you wish to skip
                    ahead from the input transport.  When importing a large
                    index, things can go wrong, be it connectivity, crashes,
                    someone forgetting to `screen`, etc.  This allows you
                    to start the dump again from the last known line written
                    (as logged by the `offset` in the output).  Please be
                    advised that since no sorting is specified when the
                    dump is initially created, there's no real way to
                    guarantee that the skipped rows have already been
                    written/parsed.  This is more of an option for when
                    you want to get most data as possible in the index
                    without concern for losing some rows in the process,
                    similar to the `timeout` option.
                    (default: 0)
                    Provide a custom js file to us as the input transport
                    Provide a custom js file to us as the output transport
                    When using a custom outputTransport, should log lines
                    be appended to the output stream?
                    (default: true, except for `$`)
                    When using Amazon Elasticsearch Service proteced by
                    AWS Identity and Access Management (IAM), provide
                    your Access Key ID and Secret Access Key
                    This page

Elasticsearch's Scroll API

Elasticsearch provides a scroll API to fetch all documents of an index starting form (and keeping) a consistent snapshot in time, which we use under the hood. This method is safe to use for large exports since it will maintain the result set in cache for the given period of time.

NOTE: only works for --output


This package also ships with a second binary, multielasticdump. This is a wrapper for the normal elasticdump binary, which provides a limited option set, but will run elasticdump in parallel across many indexes at once. It runs a process which forks into n (default your running host's # of CPUs) subprocesses running elasticdump.

The limited option set includes:

  • parallel: os.cpus(),
  • match: '^.*$',
  • input: null,
  • output: null,
  • scrollTime: '10m',
  • limit: 100,
  • offset: 100,
  • direction: dump

If the --direction is dump, which is the default, --input MUST be a URL for the base location of an ElasticSearch server (i.e. http://localhost:9200) and --output MUST be a directory. Each index that does match will have a data, mapping, and analyzer file created.

For loading files that you have dumped from multielasticsearch, --direction should be set to load, --input MUST be a directory of a multielasticsearch dump and --output MUST be a Elasticsearch server URL.

The new options, --parallel is how many forks should be run simultaneously and --match is used to filter which indexes should be dumped/loaded (regex).


  • this tool is likley to require Elasticsearch version 1.0.0 or higher
  • elasticdump (and elasticsearch in general) will create indices if they don't exist upon import
  • when exporting from elasticsearch, you can have export an entire index (--input="http://localhost:9200/index") or a type of object from that index (--input="http://localhost:9200/index/type"). This requires ElasticSearch 1.2.0 or higher
  • If elasticsearch is in a sub-directory, index and type must be provided with a separate argument (--input="http://localhost:9200/sub/directory --input-index=index/type"). Using --input-index=/ will include all indices and types.
  • we are using the put method to write objects. This means new objects will be created and old objects with the same ID will be updated
  • the file transport will not overwrite any existing files, it will throw an exception of the file already exists
  • If you need basic http auth, you can use it like this: --input=
  • if you choose a stdio output (--output=$), you can also request a more human-readable output with --format=human
  • if you choose a stdio output (--output=$), all logging output will be suppressed

Inspired by and

Built at TaskRabbit

Docker Pull Command
Source Repository