File tree Expand file tree Collapse file tree 2 files changed +7
-6
lines changed
share/github-backup-utils Expand file tree Collapse file tree 2 files changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -38,16 +38,16 @@ if echo 'set -o pipefail; ! test -e /data/user/common/es-scan-complete && test -
38
38
fi
39
39
fi
40
40
41
- current_index=audit_log- $( ghe-ssh " $host " ' date +"%Y-%m"' )
41
+ current_index=" audit_log(-[0-9]+)?- $( ghe-ssh " $host " ' date +"%Y-%m"' ) (-[0-9]+)? "
42
42
43
43
for index in $indices ; do
44
- if [ -f $GHE_DATA_DIR /current/audit-log/$index .gz -a -f $GHE_DATA_DIR /current/audit-log/$index .gz.complete -a $index \< $current_index ]; then
44
+ if [[ -f $GHE_DATA_DIR /current/audit-log/$index .gz && -f $GHE_DATA_DIR /current/audit-log/$index .gz.complete && ! $index =~ $current_index ] ]; then
45
45
# Hard link any older indices that are complete, since these won't change
46
46
ln $GHE_DATA_DIR /current/audit-log/$index .gz $GHE_SNAPSHOT_DIR /audit-log/$index .gz
47
47
ln $GHE_DATA_DIR /current/audit-log/$index .gz.complete $GHE_SNAPSHOT_DIR /audit-log/$index .gz.complete
48
48
else
49
49
ghe-ssh " $host " " /usr/local/share/enterprise/ghe-es-dump-json \" http://localhost:$es_port /$index \" " | gzip > $GHE_SNAPSHOT_DIR /audit-log/$index .gz
50
- if [ $index \< $current_index ]; then
50
+ if [[ ! $index =~ $current_index ] ]; then
51
51
touch $GHE_SNAPSHOT_DIR /audit-log/$index .gz.complete
52
52
fi
53
53
fi
Original file line number Diff line number Diff line change @@ -19,12 +19,13 @@ GHE_HOSTNAME="$1"
19
19
# Perform a host-check and establish GHE_REMOTE_XXX variables.
20
20
ghe_remote_version_required " $GHE_HOSTNAME "
21
21
22
- last_index=$( ghe-ssh " $GHE_HOSTNAME " ' curl -s "localhost:9201/_cat/indices/audit_log*"' | cut -d ' ' -f 3 | sort | tail -2 | head -1)
23
-
24
22
indices=$( ls -1 $GHE_DATA_DIR /$GHE_RESTORE_SNAPSHOT /audit-log/* .gz 2> /dev/null | xargs -I{} -n1 basename {} .gz)
25
23
24
+ last_month=" audit_log(-[0-9]+)?-$( ghe-ssh " $GHE_HOSTNAME " ' date -d "1 month ago" +"%Y-%m"' ) (-[0-9]+)?"
25
+ current_month=" audit_log(-[0-9]+)?-$( ghe-ssh " $GHE_HOSTNAME " ' date +"%Y-%m"' ) (-[0-9]+)?"
26
+
26
27
for index in $indices ; do
27
- if [ -z " $last_index " ] || ! [ $index \< $last_index ]; then
28
+ if ! ghe-ssh " $GHE_HOSTNAME " " curl -f -s -XGET http://localhost:9201/ $index " || [[ $index =~ $last_month ]] || [[ $index =~ $current_month ] ]; then
28
29
ghe_verbose " * Restoring $index "
29
30
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
30
31
fi
You can’t perform that action at this time.
0 commit comments