docker pull taskrabbit/elasticsearch-dump



  1. 导出索引内的数据
docker run --rm -ti -v /tmp/data:/tmp taskrabbit/elasticsearch-dump --input=http://es_address:9200/my_index --output=/tmp/index_data.json --type=data


  1. 导出索引的mapping
docker run --rm -ti -v /tmp/data:/tmp taskrabbit/elasticsearch-dump --input=http://es_address:9200/my_index --output=/tmp/index_mapping.json --type=mapping



  1. 导入索引数据
docker run --rm -ti -v /tmp/data:/tmp taskrabbit/elasticsearch-dump --output=http://es_address:9200/my_index --input=/tmp/index_data.json --type=data
  1. 导入索引mapping
docker run --rm -ti -v /tmp/data:/tmp taskrabbit/elasticsearch-dump --output=http://es_address:9200/my_index --input=/tmp/index_mapping.json --type=mapping


更多实用方法参考 https://github.com/elasticsearch-dump/elasticsearch-dump

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)
                    Overwrite output file if it exists
                    (default: false)                    
                    How many objects to move in batch per operation
                    limit is approximate for file streams
                    (default: 100)
                    How many objects to retrieve
                    (default: -1 -> no limit)
                    The maximum number of requests the can be made concurrently to a specified transport.
                    (default: 1)       
                    The length of time in milliseconds in which up to <intervalCap> requests can be made
                    before the interval request count resets. Must be finite.
                    (default: 5000)       
                    The maximum number of transport requests that can be made within a given <concurrencyInterval>.
                    (default: 5)
                    If true, any incomplete requests from a <concurrencyInterval> will be carried over to
                    the next interval, effectively reducing the number of new requests that can be created
                    in that next interval.  If false, up to <intervalCap> requests can be created in the
                    next interval regardless of the number of incomplete requests from the previous interval.
                    (default: true)                                                                                       
                    Delay in milliseconds between getting data from an inputTransport and sending it to an
                     (default: 1)
                    Display the elasticsearch commands being used
                    (default: false)
                    Suppress all messages except for errors
                    (default: false)
                    What are we exporting?
                    (default: data, options: [settings, analyzer, data, mapping, alias, template])
                    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 values are
                      if ES > 5
                        `'{"query": { "match_all": {} }, "stored_fields": ["*"], "_source": true }'`
                        `'{"query": { "match_all": {} }, "fields": ["*"], "_source": true }'`
                    Add custom headers to Elastisearch requests (helpful when
                    your Elasticsearch instance sits behind a proxy)
                    (default: '{"User-Agent": "elasticdump"}')
                    Add custom parameters to Elastisearch requests uri. Helpful when you for example
                    want to use elasticsearch preference
                    (default: null)
                    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)
                    Disable input index refresh.
                      1. Much increase index speed
                      2. Much less hardware requirements
                      1. Recently added data may not be indexed
                    Recommended to use with big data indexing,
                    where speed and system health in a higher priority
                    than recently added data.
                    Provide a custom js file to use as the input transport
                    Provide a custom js file to use as the output transport
                    When using a custom outputTransport, should log lines
                    be appended to the output stream?
                    (default: true, except for `$`)
                    A javascript, which will be called to modify documents
                    before writing it to destination. global variable 'doc'
                    is available.
                    Example script for computing a new field 'f2' as doubled
                    value of field 'f1':
                        doc._source["f2"] = doc._source.f1 * 2;
                    May be used multiple times.
                    Additionally, transform may be performed by a module. See [Module Transform](#module-transform) below.
                    Use [standard](https://aws.amazon.com/blogs/security/a-new-and-standardized-way-to-manage-credentials-in-the-aws-sdks/) location and ordering for resolving credentials including environment variables, config files, EC2 and ECS metadata locations
                    _Recommended option for use with AWS_
                    When using Amazon Elasticsearch Service protected by
                    AWS Identity and Access Management (IAM), provide
                    your Access Key ID and Secret Access Key.
                    --sessionToken can also be optionally provided if using temporary credentials
                    Alternative to --awsAccessKeyId and --awsSecretAccessKey,
                    loads credentials from a specified profile in aws ini file.
                    For greater flexibility, consider using --awsChain
                    and setting AWS_PROFILE and AWS_CONFIG_FILE
                    environment variables to override defaults if needed
                    Override the default aws ini file name when using --awsIniFileProfile
                    Filename is relative to ~/.aws/
                    (default: config)
                    Support big integer numbers
                    Integer indicating the number of times a request should be automatically re-attempted before failing
                    when a connection fails with one of the following errors `ECONNRESET`, `ENOTFOUND`, `ESOCKETTIMEDOUT`,
                    (default: 0)
                    Integer indicating the back-off/break period between retry attempts (milliseconds)
                    (default : 5000)            
                    Comma-separated list of meta-fields to be parsed  
                    supports file splitting.  This value must be a string supported by the **bytes** module.     
                    The following abbreviations must be used to signify size in terms of units         
                    b for bytes
                    kb for kilobytes
                    mb for megabytes
                    gb for gigabytes
                    tb for terabytes
                    e.g. 10mb / 1gb / 1tb
                    Partitioning helps to alleviate overflow/out of memory exceptions by efficiently segmenting files
                    into smaller chunks that then be merged if needs be.
                    gzip data before sending outputting to file 
                    AWS access key ID
                    AWS secret access key
                    AWS region
                    AWS endpoint can be used for AWS compatible backends such as
                    OpenStack Swift and OpenStack Ceph
                    Use SSL to connect to AWS [default true]
--s3ForcePathStyle  Force path style URLs for S3 objects [default false]
                    gzip data before sending to s3  
                    The base number of milliseconds to use in the exponential backoff for operation retries. (s3)
                    Activate custom customBackoff function. (s3)
                    Enable TLS X509 client authentication
--cert, --input-cert, --output-cert
                    Client certificate file. Use --cert if source and destination are identical.
                    Otherwise, use the one prefixed with --input or --output as needed.
--key, --input-key, --output-key
                    Private key file. Use --key if source and destination are identical.
                    Otherwise, use the one prefixed with --input or --output as needed.
--pass, --input-pass, --output-pass
                    Pass phrase for the private key. Use --pass if source and destination are identical.
                    Otherwise, use the one prefixed with --input or --output as needed.
--ca, --input-ca, --output-ca
                    CA certificate. Use --ca if source and destination are identical.
                    Otherwise, use the one prefixed with --input or --output as needed.
--inputSocksProxy, --outputSocksProxy
                    Socks5 host address
--inputSocksPort, --outputSocksPort
                    Socks5 host port
                    This page


  1. 运行后报错es连接失败