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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dc0fd72a92d1558e5220e4c9e29890fc7a42a5ef
4
- data.tar.gz: 6728b0a29e270e15d12cf471930663e6bb4e8bc9
3
+ metadata.gz: 5a73dd8a14f8349c15f7025f1fbbea90772fb4f7
4
+ data.tar.gz: ee6bf2602aad552ca523ee12d434dd709cba4bd6
5
5
  SHA512:
6
- metadata.gz: 8383b52217f7b1e8ce01b6bee2a4360a548c4f73436922aa525ec2ba77bf462ace38c29589f4547c589bfd0f0f6315742d9640e8c49773a575b3161aaba694fd
7
- data.tar.gz: 8f5f0cf9324f4615310c892f66418ef4ae8d786c74d04388a14e7e7150e26b6a375682dab3b3dfe8bb9f7b565ae7ca691a2d5a4f4a3de33eb4b86ec6e1220e16
6
+ metadata.gz: a7a8a347d841836fadf6e93af7f8d77907c068312fd1aa62869ecaeb179579e20ebe4d500072b69133aac8107ebd622b3d575035ef19b26e80c7030e419505e4
7
+ data.tar.gz: 5a23239b7b560133892b696fb695ab4276d102d47e09440fefc925738f55ebde7b897a7de77d228239a594a0c95d465cd1bcb7695598123fe903c06fbafaa942
@@ -1,5 +1,5 @@
1
1
  module EverTools
2
2
  class ElasticsearchS3Backup
3
- VERSION = '1.1.2'
3
+ VERSION = '1.1.3'
4
4
  end
5
5
  end
@@ -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']}/#{@backup_repo}",
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: @backup_repo,
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}/#{@snapshot_label})…"
124
- r = es_api.snapshot.create repository: @backup_repo,
125
- snapshot: @snapshot_label,
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: @backup_repo,
137
- snapshot: @snapshot_label,
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elasticsearch_s3_backup
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Herot