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
147
147
failures=" $failures redis"
148
148
fi
149
149
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
153
155
154
156
echo " Backing up hookshot logs ..."
155
157
ghe-backup-es-hookshot ||
Original file line number Diff line number Diff line change @@ -19,14 +19,24 @@ ghe_remote_version_required "$host"
19
19
# Make sure root backup dir exists if this is the first run
20
20
mkdir -p " $GHE_SNAPSHOT_DIR /audit-log"
21
21
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
+
23
33
current_index=audit_log-$( ghe-ssh " $host " ' date +"%Y-%m"' )
24
34
25
35
for index in $indices ; do
26
36
if [ -f $GHE_DATA_DIR /current/audit-log/$index .gz -a $index \< $current_index ]; then
27
37
# Hard link any older indices since they are read only and won't change
28
38
ln $GHE_DATA_DIR /current/audit-log/$index .gz $GHE_SNAPSHOT_DIR /audit-log/$index .gz
29
39
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
31
41
fi
32
42
done
Original file line number Diff line number Diff line change 3
3
# Fake curl command stub for tests.
4
4
set -e
5
5
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
+
6
11
# Write args to stdout
7
12
echo " $@ "
8
13
You can’t perform that action at this time.
0 commit comments