es_dump_restore 0.0.8 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/lib/es_dump_restore/app.rb +1 -0
- data/lib/es_dump_restore/es_client.rb +21 -11
- data/lib/es_dump_restore/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 08fa2b9eb215b8ff28dc83c19a9c4b1e952d32ff
|
4
|
+
data.tar.gz: febbb67ee5b1faf6157d65323da09177e7e50a91
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ee784a1b7992d131ebcabd70f7be9d6740597c6ab0339a55db6423cb140a05468113fba1e081cdf3d5fcb51ace39b102077ac24bd9d95f1cb9bae898985ddce5
|
7
|
+
data.tar.gz: 108636726d2ee7780cdd350e2e39c5218b3c9d557680cc4eb30c17ce36e11f99aba734cffbe25741efa64d7e8c57cdbf9c171191e2bbb96b7eabcbbed0ac51f4
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
# Version 0.0.10 - December 3, 2014
|
2
|
+
|
3
|
+
* Fixes a bug introduced in 0.0.9 (thanks again to Noa Resare for the fix!)
|
4
|
+
|
5
|
+
# Version 0.0.9 - December 2, 2014 - YANKED
|
6
|
+
|
7
|
+
* Makes it possible to use ES instances not located at server root (thanks Noa Resare for the patch!)
|
8
|
+
|
1
9
|
# Version 0.0.8 - September 9, 2014
|
2
10
|
|
3
11
|
* Added --noprogressbar option for easier usage with cron (thanks Marco Dickert for the patch!)
|
data/lib/es_dump_restore/app.rb
CHANGED
@@ -8,6 +8,7 @@ module EsDumpRestore
|
|
8
8
|
class App < Thor
|
9
9
|
|
10
10
|
option :noprogressbar, :type => :boolean # switch for showing progress bar
|
11
|
+
option :verbose, :type => :boolean # add some additional output
|
11
12
|
|
12
13
|
desc "dump URL INDEX_NAME FILENAME", "Creates a dumpfile based on the given ElasticSearch index"
|
13
14
|
def dump(url, index_name, filename)
|
@@ -11,19 +11,20 @@ module EsDumpRestore
|
|
11
11
|
@httpclient = HTTPClient.new
|
12
12
|
@index_name = index_name
|
13
13
|
|
14
|
-
@
|
14
|
+
@es_uri = base_uri
|
15
|
+
@path_prefix = type.nil? ? index_name : index_name + "/" + type
|
15
16
|
end
|
16
17
|
|
17
18
|
def mappings
|
18
|
-
request(:get,
|
19
|
+
request(:get, "#{@path_prefix}/_mapping")[index_name]
|
19
20
|
end
|
20
21
|
|
21
22
|
def settings
|
22
|
-
request(:get,
|
23
|
+
request(:get, "#{@path_prefix}/_settings")[index_name]
|
23
24
|
end
|
24
25
|
|
25
26
|
def start_scan(&block)
|
26
|
-
scroll = request(:get,
|
27
|
+
scroll = request(:get, "#{@path_prefix}/_search",
|
27
28
|
query: { search_type: 'scan', scroll: '10m', size: 500 },
|
28
29
|
body: MultiJson.dump({ query: { match_all: {} } }) )
|
29
30
|
total = scroll["hits"]["total"]
|
@@ -34,9 +35,9 @@ module EsDumpRestore
|
|
34
35
|
|
35
36
|
def each_scroll_hit(scroll_id, &block)
|
36
37
|
loop do
|
37
|
-
batch = request(:get, '
|
38
|
+
batch = request(:get, '_search/scroll', {query: {
|
38
39
|
scroll: '10m', scroll_id: scroll_id
|
39
|
-
})
|
40
|
+
}}, [404])
|
40
41
|
|
41
42
|
batch_hits = batch["hits"]
|
42
43
|
break if batch_hits.nil?
|
@@ -59,10 +60,19 @@ module EsDumpRestore
|
|
59
60
|
|
60
61
|
private
|
61
62
|
|
62
|
-
def request(method, path, options={})
|
63
|
-
request_uri = @
|
64
|
-
|
65
|
-
|
63
|
+
def request(method, path, options={}, extra_allowed_exitcodes=[])
|
64
|
+
request_uri = @es_uri + "/" + path
|
65
|
+
begin
|
66
|
+
response = @httpclient.request(method, request_uri, options)
|
67
|
+
unless response.ok? or extra_allowed_exitcodes.include? response.status
|
68
|
+
raise "Request failed with status #{response.status}: #{response.reason}"
|
69
|
+
end
|
70
|
+
MultiJson.load(response.content)
|
71
|
+
rescue Exception => e
|
72
|
+
puts "Exception caught issuing HTTP request to #{request_uri}"
|
73
|
+
puts "options: #{options}"
|
74
|
+
raise e
|
75
|
+
end
|
66
76
|
end
|
67
77
|
end
|
68
|
-
end
|
78
|
+
end
|
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: 0.0.
|
4
|
+
version: 0.0.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nat Budin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-12-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: multi_json
|