Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9705e76

Browse files
author
Mat Moore
committed
Wrappers around rummager snapshot/restore tasks
1 parent c12479c commit 9705e76

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed

elasticsearch.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,12 @@ def wait_for_status(*allowed):
9393
sleep(5)
9494

9595

96+
@task
97+
def check_recovery(index):
98+
"""Check status of an index recovery"""
99+
return run("curl -XGET 'http://localhost:9200/{index}/_recovery'".format(index=index))
100+
101+
96102
@task
97103
@serial
98104
def safe_reboot():

search.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,50 @@ def reindex_app(app):
6868
sudo('govuk_setenv default bundle exec rake -v "%s" --trace' % rake_task, user='deploy')
6969
else:
7070
util.rake(app, rake_task)
71+
72+
73+
@task
74+
def find_latest_snapshot():
75+
"""Find the latest rummager snapshot"""
76+
util.rake('rummager', 'rummager:snapshot:latest')
77+
78+
79+
@task
80+
def find_snapshot_for_date(date):
81+
"""Find the latest rummager snapshot before a date (YYYY-mm-dd HH:MM:SS)"""
82+
util.rake('rummager', 'rummager:snapshot:latest', date)
83+
84+
85+
@task
86+
def list_snapshots():
87+
"""List rummager snapshots"""
88+
util.rake('rummager', 'rummager:snapshot:list')
89+
90+
91+
@task
92+
def restore_snapshot(snapshot, groups_to_restore):
93+
"""Restore snapshots to new indices.
94+
95+
`groups_to_restore` is either 'all' or a comma separated list of aliases.
96+
"""
97+
util.rake(
98+
'rummager',
99+
'rummager:snapshot:restore',
100+
snapshot,
101+
RUMMAGER_INDEX=groups_to_restore
102+
)
103+
104+
puts(
105+
"After the recovery is complete, switch to the new indexes with rummager.switch_group_to_index"
106+
)
107+
108+
109+
@task
110+
def switch_group_to_index(group, index_name):
111+
"""Point a rummager index alias to a new index"""
112+
util.rake(
113+
'rummager',
114+
'rummager:switch_to_named_index',
115+
index_name,
116+
RUMMAGER_INDEX=group
117+
)

0 commit comments

Comments
 (0)