27
27
# Make sure root backup dir exists if this is the first run
28
28
mkdir -p " $GHE_SNAPSHOT_DIR /elasticsearch"
29
29
30
+ # Create exclude file
31
+ exclude_file=" $( mktemp) "
32
+ echo elasticsearch.yml > " $exclude_file "
33
+
34
+ # Exclude audit log indices when configuration says so and import to MySQL is complete
35
+ # as those indices will be rebuilt from MySQL during a restore
36
+ if [ " $GHE_BACKUP_ES_AUDIT_LOGS " = " no" ] && ghe-ssh " $host " test -e " /data/user/common/audit-log-import/complete" ; then
37
+ ghe_verbose " * Excluding Audit Log indices"
38
+ ghe-ssh " $host " curl -s ' http://localhost:9201/_cat/indices/audit_log?h=uuid' >> $exclude_file 2>&3
39
+ fi
40
+
30
41
# Verify that the /data/elasticsearch directory exists.
31
42
if ! ghe-ssh " $host " -- " [ -d '$GHE_REMOTE_DATA_USER_DIR /elasticsearch' ]" ; then
32
43
ghe_verbose " * The '$GHE_REMOTE_DATA_USER_DIR /elasticsearch' directory doesn't exist."
@@ -47,15 +58,16 @@ ghe-rsync -avz \
47
58
-e " ghe-ssh -p $( ssh_port_part " $host " ) " \
48
59
--rsync-path=" sudo -u elasticsearch rsync" \
49
60
$link_dest \
50
- --exclude= ' elasticsearch.yml ' \
61
+ --exclude-from= " $exclude_file " \
51
62
" $( ssh_host_part " $host " ) :$GHE_REMOTE_DATA_USER_DIR /elasticsearch/" \
52
63
" $GHE_SNAPSHOT_DIR /elasticsearch" 1>&3
53
64
54
- # Set up a trap to re-enable flushing on exit
65
+ # Set up a trap to re-enable flushing on exit and remove temp file
55
66
cleanup () {
56
67
ghe_verbose " * Enabling ES index flushing ..."
57
68
echo ' {"index":{"translog.disable_flush":false}}' |
58
69
ghe-ssh " $host " -- curl -s -XPUT " localhost:9200/_settings" -d @- > /dev/null
70
+ ghe-ssh " $host " rm -rf " $exclude_file "
59
71
}
60
72
trap ' cleanup' EXIT
61
73
trap ' exit $?' INT # ^C always terminate
@@ -72,7 +84,7 @@ ghe-rsync -avz \
72
84
-e " ghe-ssh -p $( ssh_port_part " $host " ) " \
73
85
--rsync-path=" sudo -u elasticsearch rsync" \
74
86
$link_dest \
75
- --exclude= ' elasticsearch.yml ' \
87
+ --exclude-from= " $exclude_file " \
76
88
" $( ssh_host_part " $host " ) :$GHE_REMOTE_DATA_USER_DIR /elasticsearch/" \
77
89
" $GHE_SNAPSHOT_DIR /elasticsearch" 1>&3
78
90
0 commit comments