Skip to content

Commit 27e98cb

Browse files
authored
Merge pull request #528 from github/hao-skip-audit-entries
Skip backup and retore audit_entries indiviually if binary backup is available
2 parents 39b2e05 + 6fcc90a commit 27e98cb

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,15 @@ is_skip_truncate_enabled(){
2929
ghe-ssh "$host" test -e "$GHE_REMOTE_DATA_USER_DIR/common/audit-log-import/skip_truncate"
3030
}
3131

32+
is_binary_backup(){
33+
ghe-ssh "$host" ghe-config --true "mysql.backup.binary"
34+
}
35+
3236
backup_mysql(){
37+
if is_binary_backup; then
38+
ghe_verbose "Skip backup audit_entries for Mysql since it is using binary backup"
39+
return
40+
fi
3341
if is_skip_truncate_enabled; then
3442
# As skip_truncate exists, we need to also backup the audit entries
3543
# in MySQL because Elasticsearch may not be fully synced.

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

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ is_mysql_supported(){
4646
'test \"\$ENTERPRISE_AUDIT_LOG_MYSQL_LOGGER_ENABLED\" = \"1\""' | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash
4747
}
4848

49+
is_binary_backup(){
50+
ghe-ssh "$GHE_HOSTNAME" ghe-config --true "mysql.backup.binary"
51+
}
52+
4953
# Helper function to set remote flags in `/data/user/common/audit-log-import`
5054
# if it's supported, i.e: directory exists.
5155
set_remote_flag(){
@@ -107,7 +111,17 @@ do_restore(){
107111
ghe_verbose "Elasticsearch data is available"
108112

109113
restore_es
110-
restore_mysql --only-schema
114+
115+
if is_binary_backup; then
116+
ghe_verbose "Table audit_entries is already restored by binary backup"
117+
else
118+
restore_mysql --only-schema
119+
fi
120+
return
121+
fi
122+
123+
if is_binary_backup; then
124+
ghe_verbose "Table audit_entries is already restored by binary backup"
111125
return
112126
fi
113127

0 commit comments

Comments
 (0)