Skip to content
This repository has been archived by the owner on Mar 7, 2024. It is now read-only.

Commit

Permalink
make sure the absence of audit_entries table is not fatal
Browse files Browse the repository at this point in the history
  • Loading branch information
juruen committed Jan 8, 2020
1 parent b32ed4e commit 03f3817
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
10 changes: 9 additions & 1 deletion share/github-backup-utils/ghe-backup-audit-log
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ is_skip_truncate_enabled(){
ghe-ssh "$host" test -e "$GHE_REMOTE_DATA_USER_DIR/common/audit-log-import/skip_truncate"
}

# Check whether the audit_entries table is deleted
audit_entries_deleted(){
[ -z "$(ghe-ssh "$host" -- "/usr/local/share/enterprise/github-mysql 'SHOW TABLES LIKE \"audit_entries\"'")" ]
}

is_binary_backup(){
ghe-ssh "$host" ghe-config --true "mysql.backup.binary"
}
Expand All @@ -38,7 +43,10 @@ backup_mysql(){
ghe_verbose "Skip backup audit_entries for Mysql since it is using binary backup"
return
fi
if is_skip_truncate_enabled; then

if audit_entries_deleted; then
ghe_verbose "audit_entries table does not exist"
elif is_skip_truncate_enabled; then
# As skip_truncate exists, we need to also backup the audit entries
# in MySQL because Elasticsearch may not be fully synced.
"${base_path}/ghe-backup-mysql-audit-log"
Expand Down
5 changes: 5 additions & 0 deletions share/github-backup-utils/ghe-restore-audit-log
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ restore_mysql(){

ghe_verbose "Restoring MySQL audit logs ..."

if ! mysql_table_schema_available; then
ghe_verbose "schema.gz does not exist"
return
fi

"${base_path}/ghe-restore-mysql-audit-log" "$GHE_HOSTNAME" "$only_schema"
}

Expand Down

0 comments on commit 03f3817

Please sign in to comment.