es_dump_restore 2.1.0 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +5 -2
- data/lib/es_dump_restore/app.rb +4 -4
- data/lib/es_dump_restore/es_client.rb +13 -2
- data/lib/es_dump_restore/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 92d15eebfd8d46e234d93dc0868dfbfe0f69a2a0
|
4
|
+
data.tar.gz: 937b84068b58f036d19befa6c97df87aa4b390cb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2aef2931dfc1b07cc8ccd5f522737d433db672657430347af66b8a8143b8d821371bb90a0743d365fb26137ca518bb1a918d30d9a4a3059e9e401c2f098f3277
|
7
|
+
data.tar.gz: ae8c5562157a305db99ce44229eafee4ee958b587ba4e9bd624d7306f932227805f8033473c61a1de5891857274b4086beb6bc86d7be85a44dc896a3d5d5ecfd
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -23,11 +23,11 @@ To dump an ElasticSearch index by type to a file:
|
|
23
23
|
|
24
24
|
To restore an index to an ElasticSearch server:
|
25
25
|
|
26
|
-
es_dump_restore restore ELASTIC_SEARCH_SERVER_URL DESTINATION_INDEX FILENAME_ZIP [SETTING_OVERRIDES] [BATCH_SIZE]
|
26
|
+
es_dump_restore restore ELASTIC_SEARCH_SERVER_URL DESTINATION_INDEX FILENAME_ZIP [SETTING_OVERRIDES] [BATCH_SIZE] [EXCEPTION_RETRIES]
|
27
27
|
|
28
28
|
To restore an index and set an alias to point to it:
|
29
29
|
|
30
|
-
es_dump_restore restore_alias ELASTIC_SEARCH_SERVER_URL DESTINATION_ALIAS DESTINATION_INDEX FILENAME_ZIP [SETTING_OVERRIDES] [BATCH_SIZE]
|
30
|
+
es_dump_restore restore_alias ELASTIC_SEARCH_SERVER_URL DESTINATION_ALIAS DESTINATION_INDEX FILENAME_ZIP [SETTING_OVERRIDES] [BATCH_SIZE] [EXCEPTION_RETRIES]
|
31
31
|
|
32
32
|
This loads the dump into an index named `DESTINATION_INDEX`, and once the load
|
33
33
|
is complete sets the alias `DESTINATION_ALIAS` to point to it. If
|
@@ -53,6 +53,9 @@ documents which will be sent to elasticsearch at once. This defaults to 1000,
|
|
53
53
|
which is normally fine, but if you have particularly complex documents or
|
54
54
|
mappings this might need reducing to avoid timeouts.
|
55
55
|
|
56
|
+
If `EXCEPTION_RETRIES` is set to an integer it tells the bulk load process how
|
57
|
+
many times is should retry when a timeout is raised. This defaults to 1.
|
58
|
+
|
56
59
|
## Contributing
|
57
60
|
|
58
61
|
1. Fork it
|
data/lib/es_dump_restore/app.rb
CHANGED
@@ -26,8 +26,8 @@ module EsDumpRestore
|
|
26
26
|
end
|
27
27
|
|
28
28
|
desc "restore URL INDEX_NAME FILENAME", "Restores a dumpfile into the given ElasticSearch index"
|
29
|
-
def restore(url, index_name, filename, overrides = nil, batch_size = 1000)
|
30
|
-
client = EsClient.new(url, index_name, nil)
|
29
|
+
def restore(url, index_name, filename, overrides = nil, batch_size = 1000, exception_retries = 1)
|
30
|
+
client = EsClient.new(url, index_name, nil, exception_retries)
|
31
31
|
|
32
32
|
Dumpfile.read(filename) do |dumpfile|
|
33
33
|
client.create_index(dumpfile.index, overrides)
|
@@ -42,8 +42,8 @@ module EsDumpRestore
|
|
42
42
|
|
43
43
|
desc "restore_alias URL ALIAS_NAME INDEX_NAME FILENAME", "Restores a dumpfile into the given ElasticSearch index, and then sets the alias to point at that index, removing any existing indexes pointed at by the alias"
|
44
44
|
def restore_alias(url, alias_name, index_name, filename, overrides = nil,
|
45
|
-
batch_size = 1000)
|
46
|
-
client = EsClient.new(url, index_name, nil)
|
45
|
+
batch_size = 1000, exception_retries = 1)
|
46
|
+
client = EsClient.new(url, index_name, nil, exception_retries)
|
47
47
|
client.check_alias alias_name
|
48
48
|
|
49
49
|
Dumpfile.read(filename) do |dumpfile|
|
@@ -7,12 +7,13 @@ module EsDumpRestore
|
|
7
7
|
attr_accessor :base_uri
|
8
8
|
attr_accessor :index_name
|
9
9
|
|
10
|
-
def initialize(base_uri, index_name, type)
|
10
|
+
def initialize(base_uri, index_name, type, exception_retries=1)
|
11
11
|
@httpclient = HTTPClient.new
|
12
12
|
@index_name = index_name
|
13
13
|
|
14
14
|
@es_uri = base_uri
|
15
15
|
@path_prefix = type.nil? ? index_name : index_name + "/" + type
|
16
|
+
@exception_retries = exception_retries
|
16
17
|
end
|
17
18
|
|
18
19
|
def mappings
|
@@ -124,7 +125,17 @@ module EsDumpRestore
|
|
124
125
|
end
|
125
126
|
|
126
127
|
def bulk_index(data)
|
127
|
-
|
128
|
+
retries = 0
|
129
|
+
begin
|
130
|
+
request(:post, "#{@path_prefix}/_bulk", :body => data)
|
131
|
+
rescue HTTPClient::TimeoutError => e
|
132
|
+
if retries < @exception_retries
|
133
|
+
retries += 1
|
134
|
+
puts "Retrying (#{retries} of #{@exception_retries}) '#{@path_prefix}/_bulk'"
|
135
|
+
retry
|
136
|
+
end
|
137
|
+
raise e
|
138
|
+
end
|
128
139
|
end
|
129
140
|
|
130
141
|
private
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: es_dump_restore
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nat Budin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-10-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: multi_json
|
@@ -135,7 +135,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
135
135
|
version: '0'
|
136
136
|
requirements: []
|
137
137
|
rubyforge_project:
|
138
|
-
rubygems_version: 2.4
|
138
|
+
rubygems_version: 2.6.4
|
139
139
|
signing_key:
|
140
140
|
specification_version: 4
|
141
141
|
summary: Dump ElasticSearch indexes to files and restore them back
|