Module: SnapDelete
Overview
Index snapshots deleting operations
Constant Summary
Constants included
from Logging
Logging::SEVERITY_COLORS
Instance Method Summary
collapse
Methods included from Logging
configure_logger_for, #log, log_level, logger_for
Instance Method Details
#do_snapdelete(indices) ⇒ Object
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/elastic_manager/snapdelete.rb', line 33
def do_snapdelete(indices)
indices.each do |index|
next if skip_index?(index, 'snapdelete')
snapshot_name = "snapshot_#{index}"
snapshot_repo = @elastic.find_snapshot_repo
if @elastic.snapshot_exist?(snapshot_name, snapshot_repo)
elastic_action_with_log('delete_snapshot', snapshot_name, snapshot_repo)
else
log.warn "#{index} snapshot #{snapshot_name} not found"
end
end
end
|
#snapdelete ⇒ Object
48
49
50
51
52
53
54
|
# File 'lib/elastic_manager/snapdelete.rb', line 48
def snapdelete
indices, date_from, date_to, daysago = prepare_vars
prechecks(date_from, date_to)
indices = snapdelete_populate_indices(indices, date_from, date_to, daysago)
log.debug indices.inspect
do_snapdelete(indices)
end
|
#snapdelete_populate_indices(indices, date_from, date_to, daysago) ⇒ Object
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/elastic_manager/snapdelete.rb', line 9
def snapdelete_populate_indices(indices, date_from, date_to, daysago)
result = []
if indices.length == 1 && indices.first == '_all'
result = @elastic.all_indices_in_snapshots(date_from, date_to, daysago, @config)
else
if date_from.nil?
result = @elastic.all_indices_in_snapshots(date_from, date_to, daysago, @config).select { |r| r.start_with?(*indices) }
else
date_from.upto(date_to) do |date|
indices.each do |index|
date_formatted = date.to_s.tr('-', '.')
result << "#{index}-#{date_formatted}"
end
end
end
end
return result unless result.empty?
log.fatal 'no indices for work'
exit 1
end
|