Skip to content

Commit 4f16669

Browse files
committed
Set ES port by GHE version
1 parent a89ec70 commit 4f16669

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,13 @@ ghe_remote_version_required "$host"
1919
# Make sure root backup dir exists if this is the first run
2020
mkdir -p "$GHE_SNAPSHOT_DIR/audit-log"
2121

22-
if ! indices=$(ghe-ssh "$host" 'curl -s "localhost:9201/_cat/indices/audit_log*?h=index"'); then
22+
if [ $GHE_VERSION_MAJOR -ge 2 ] && [ $GHE_VERSION_MINOR -ge 2 ]; then
23+
es_port=9201
24+
else
25+
es_port=9200
26+
fi
27+
28+
if ! indices=$(ghe-ssh "$host" "curl -s \"localhost:$es_port/_cat/indices/audit_log*?h=index"\"); then
2329
echo "Error: failed to retrieve audit log indices." 1>&2
2430
exit 1
2531
fi
@@ -31,6 +37,6 @@ for index in $indices; do
3137
# Hard link any older indices since they are read only and won't change
3238
ln $GHE_DATA_DIR/current/audit-log/$index.gz $GHE_SNAPSHOT_DIR/audit-log/$index.gz
3339
else
34-
ghe-ssh "$host" "/usr/local/share/enterprise/ghe-es-dump-json 'http://localhost:9201/$index'" | gzip > $GHE_SNAPSHOT_DIR/audit-log/$index.gz
40+
ghe-ssh "$host" "/usr/local/share/enterprise/ghe-es-dump-json \"http://localhost:$es_port/$index\"" | gzip > $GHE_SNAPSHOT_DIR/audit-log/$index.gz
3541
fi
3642
done

0 commit comments

Comments
 (0)