Skip to content

Commit bd82bbf

Browse files
authored
Merge pull request #328 from github/snh/es-cluster-restore
Refresh the existing indices when restoring Elasticsearch indices to cluster
2 parents 7a7e1c3 + a25c326 commit bd82bbf

File tree

6 files changed

+11
-11
lines changed

6 files changed

+11
-11
lines changed

bin/ghe-restore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ elif [ "$GHE_VERSION_MAJOR" -ge 2 ]; then
344344
fi
345345

346346
if $cluster; then
347-
echo "Restoring ElasticSearch Audit logs"
347+
echo "Restoring Elasticsearch Audit logs"
348348
ghe-restore-es-audit-log "$GHE_HOSTNAME" 1>&3
349349

350350
echo "Restoring hookshot logs ..."

share/github-backup-utils/ghe-backup-es-audit-log

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env bash
22
#/ Usage: ghe-backup-es-audit-log
3-
#/ Take a backup of audit logs in ElasticSearch.
3+
#/ Take a backup of audit logs in Elasticsearch.
44
#/
55
#/ Note: This command typically isn't called directly. It's invoked by
66
#/ ghe-backup.

share/github-backup-utils/ghe-backup-es-hookshot

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env bash
22
#/ Usage: ghe-backup-es-hookshot
3-
#/ Take a backup of hookshot logs in ElasticSearch.
3+
#/ Take a backup of hookshot logs in Elasticsearch.
44
#/
55
#/ Note: This command typically isn't called directly. It's invoked by
66
#/ ghe-backup.

share/github-backup-utils/ghe-restore-es-audit-log

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#!/usr/bin/env bash
22
#/ Usage: ghe-restore-es-audit-log
3-
#/ Take a backup of audit logs in ElasticSearch.
3+
#/ Restores a backup of audit logs to Elasticsearch.
44
#/
55
#/ Note: This command typically isn't called directly. It's invoked by
6-
#/ ghe-backup.
6+
#/ ghe-restore.
77
set -e
88

99
# Bring in the backup configuration
@@ -19,14 +19,14 @@ GHE_HOSTNAME="$1"
1919
# Perform a host-check and establish GHE_REMOTE_XXX variables.
2020
ghe_remote_version_required "$GHE_HOSTNAME"
2121

22-
last_index=$(ghe-ssh "$GHE_HOSTNAME" 'curl -s "localhost:9201/_cat/indices/audit_log*"' | cut -d ' ' -f 3 | sort | tail -1)
22+
last_index=$(ghe-ssh "$GHE_HOSTNAME" 'curl -s "localhost:9201/_cat/indices/audit_log*"' | cut -d ' ' -f 3 | sort | tail -2 | head -1)
2323

2424
indices=$(ls -1 $GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/audit-log/*.gz 2>/dev/null | xargs -I{} -n1 basename {} .gz)
2525

2626
for index in $indices; do
2727
if [ -z "$last_index" ] || ! [ $index \< $last_index ]; then
28-
echo "Restoring $index"
29-
gzip -dc $GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/audit-log/$index.gz | ghe-ssh "$GHE_HOSTNAME" "/usr/local/share/enterprise/ghe-es-load-json 'http://localhost:9201/$index'"
28+
ghe_verbose "* Restoring $index"
29+
gzip -dc $GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/audit-log/$index.gz | ghe-ssh "$GHE_HOSTNAME" "/usr/local/share/enterprise/ghe-es-load-json 'http://localhost:9201/$index'" 1>&3
3030
fi
3131
done
3232

share/github-backup-utils/ghe-restore-es-hookshot

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env bash
22
#/ Usage: ghe-restore-es-hookshot
3-
#/ Restores a backup of hookshot logs to ElasticSearch.
3+
#/ Restores a backup of hookshot logs to Elasticsearch.
44
#/
55
#/ Note: This command typically isn't called directly. It's invoked by
66
#/ ghe-restore.
@@ -19,7 +19,7 @@ GHE_HOSTNAME="$1"
1919
# Perform a host-check and establish GHE_REMOTE_XXX variables.
2020
ghe_remote_version_required "$GHE_HOSTNAME"
2121

22-
last_index=$(ghe-ssh "$GHE_HOSTNAME" 'curl -s "localhost:9201/_cat/indices/hookshot-logs-*"' | cut -d ' ' -f 3 | sort | tail -1)
22+
last_index=$(ghe-ssh "$GHE_HOSTNAME" 'curl -s "localhost:9201/_cat/indices/hookshot-logs-*"' | cut -d ' ' -f 3 | sort | tail -2 | head -1)
2323

2424
indices=$(ls -1 $GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/hookshot/*.gz 2>/dev/null | xargs -I{} -n1 basename {} .gz)
2525

share/github-backup-utils/ghe-restore-es-tarball

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ bm_start "$(basename $0)"
2121
# us run this script directly.
2222
: ${GHE_RESTORE_SNAPSHOT:=current}
2323

24-
# Restore ElasticSearch indices from tarball snapshot.
24+
# Restore Elasticsearch indices from tarball snapshot.
2525
ghe-ssh "$GHE_HOSTNAME" -- 'ghe-import-es-indices' \
2626
< "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/elasticsearch.tar" 1>&3
2727

0 commit comments

Comments
 (0)