File tree Expand file tree Collapse file tree 3 files changed +22
-5
lines changed
share/github-backup-utils Expand file tree Collapse file tree 3 files changed +22
-5
lines changed Original file line number Diff line number Diff line change @@ -147,9 +147,11 @@ else
147147 failures=" $failures redis"
148148fi
149149
150- echo " Backing up audit log ..."
151- ghe-backup-es-audit-log ||
152- failures=" $failures audit-log"
150+ if [ $GHE_VERSION_MAJOR -ge 2 ]; then
151+ echo " Backing up audit log ..."
152+ ghe-backup-es-audit-log ||
153+ failures=" $failures audit-log"
154+ fi
153155
154156echo " Backing up hookshot logs ..."
155157ghe-backup-es-hookshot ||
Original file line number Diff line number Diff line change @@ -19,14 +19,24 @@ ghe_remote_version_required "$host"
1919# Make sure root backup dir exists if this is the first run
2020mkdir -p " $GHE_SNAPSHOT_DIR /audit-log"
2121
22- indices=$( ghe-ssh " $host " ' curl -s "localhost:9201/_cat/indices/audit_log*"' | cut -d ' ' -f 3)
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
29+ echo " Error: failed to retrieve audit log indices." 1>&2
30+ exit 1
31+ fi
32+
2333current_index=audit_log-$( ghe-ssh " $host " ' date +"%Y-%m"' )
2434
2535for index in $indices ; do
2636 if [ -f $GHE_DATA_DIR /current/audit-log/$index .gz -a $index \< $current_index ]; then
2737 # Hard link any older indices since they are read only and won't change
2838 ln $GHE_DATA_DIR /current/audit-log/$index .gz $GHE_SNAPSHOT_DIR /audit-log/$index .gz
2939 else
30- 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
3141 fi
3242done
Original file line number Diff line number Diff line change 33# Fake curl command stub for tests.
44set -e
55
6+ # Return empty list of indexes for ghe-backup-es-audit-log
7+ if echo " $@ " | grep -q ' _cat/indices/audit_log\*?h=index$' ; then
8+ exit 0
9+ fi
10+
611# Write args to stdout
712echo " $@ "
813
You can’t perform that action at this time.
0 commit comments