elasticsearch_s3_backup 1.1.2 → 1.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/elasticsearch_s3_backup/version.rb +1 -1
- data/lib/elasticsearch_s3_backup.rb +16 -11
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5a73dd8a14f8349c15f7025f1fbbea90772fb4f7
|
4
|
+
data.tar.gz: ee6bf2602aad552ca523ee12d434dd709cba4bd6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a7a8a347d841836fadf6e93af7f8d77907c068312fd1aa62869ecaeb179579e20ebe4d500072b69133aac8107ebd622b3d575035ef19b26e80c7030e419505e4
|
7
|
+
data.tar.gz: 5a23239b7b560133892b696fb695ab4276d102d47e09440fefc925738f55ebde7b897a7de77d228239a594a0c95d465cd1bcb7695598123fe903c06fbafaa942
|
@@ -21,7 +21,7 @@ module EverTools
|
|
21
21
|
:elasticsearch_auth_file,
|
22
22
|
:cluster_name
|
23
23
|
|
24
|
-
attr_reader :conf, :backup_repo
|
24
|
+
attr_reader :conf, :backup_repo, :snapshot_label
|
25
25
|
|
26
26
|
def initialize
|
27
27
|
@conf = OpenStruct.new(YAML.load_file('/etc/s3_backup.yml'))
|
@@ -61,7 +61,12 @@ module EverTools
|
|
61
61
|
def es_api
|
62
62
|
@es_api ||= begin
|
63
63
|
es_host = @conf['es_host'] || 'localhost'
|
64
|
-
Elasticsearch::Client.new host: "http://#{auth}@#{es_host}:9200"
|
64
|
+
Elasticsearch::Client.new host: "http://#{auth}@#{es_host}:9200",
|
65
|
+
transport_options: {
|
66
|
+
request: {
|
67
|
+
timeout: 1200
|
68
|
+
}
|
69
|
+
}
|
65
70
|
end
|
66
71
|
end
|
67
72
|
|
@@ -89,13 +94,13 @@ module EverTools
|
|
89
94
|
new_repo_params = new_repo_params.merge(
|
90
95
|
type: 's3',
|
91
96
|
settings: {
|
92
|
-
base_path: "/elasticsearch/#{cluster_name}/#{conf['env']}/#{
|
97
|
+
base_path: "/elasticsearch/#{cluster_name}/#{conf['env']}/#{backup_repo}",
|
93
98
|
server_side_encryption: true
|
94
99
|
}
|
95
100
|
)
|
96
101
|
|
97
102
|
logger.info 'Creating a new monthly ES backup repo…'
|
98
|
-
es_api.snapshot.create_repository repository:
|
103
|
+
es_api.snapshot.create_repository repository: backup_repo,
|
99
104
|
body: new_repo_params
|
100
105
|
end
|
101
106
|
|
@@ -120,21 +125,21 @@ module EverTools
|
|
120
125
|
|
121
126
|
def create_snapshot
|
122
127
|
# Make a backup (full on new month, incremental otherwise)
|
123
|
-
logger.info "Starting a new backup (#{backup_repo}/#{
|
124
|
-
r = es_api.snapshot.create repository:
|
125
|
-
snapshot:
|
128
|
+
logger.info "Starting a new backup (#{backup_repo}/#{snapshot_label})…"
|
129
|
+
r = es_api.snapshot.create repository: backup_repo,
|
130
|
+
snapshot: snapshot_label,
|
126
131
|
wait_for_completion: true
|
132
|
+
fail "Snapshot failed! #{r.inspect}" if r['snapshot']['failures'].any?
|
127
133
|
logger.info 'Snapshot complete. Time: ' \
|
128
134
|
"#{r['snapshot']['duration_in_millis']}. " \
|
129
135
|
"Results: #{r['snapshot']['shards'].inspect}"
|
130
|
-
fail "Snapshot failed! #{r.inspect}" if r['snapshot']['failures'].any?
|
131
136
|
end
|
132
137
|
|
133
138
|
def restore_test_index
|
134
139
|
# Restore just the backup_test index to a new index
|
135
140
|
logger.info 'Restoring the backup_test index…'
|
136
|
-
es_api.snapshot.restore repository:
|
137
|
-
snapshot:
|
141
|
+
es_api.snapshot.restore repository: backup_repo,
|
142
|
+
snapshot: snapshot_label,
|
138
143
|
wait_for_completion: true,
|
139
144
|
body: {
|
140
145
|
indices: @backup_test_index,
|
@@ -195,7 +200,7 @@ module EverTools
|
|
195
200
|
rescue Exception => e # Need to rescue "Exception" so that Sentry gets it
|
196
201
|
notify e
|
197
202
|
logger.fatal e.message
|
198
|
-
logger.fatal e.backtrace
|
203
|
+
logger.fatal e.backtrace.join("\n")
|
199
204
|
raise e
|
200
205
|
end
|
201
206
|
# rubocop:enable Metrics/AbcSize, Lint/RescueException
|