Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Output MySQL backup strategy for clarity during backup and restore #610

Merged
merged 7 commits into from
May 14, 2020
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion bin/ghe-backup
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,11 @@ ghe-ssh "$GHE_HOSTNAME" -- 'ghe-export-ssh-host-keys' > ssh-host-keys.tar ||
failures="$failures ssh-host-keys"
bm_end "ghe-export-ssh-host-keys"

echo "Backing up MySQL database ..."
if is_binary_backup_feature_on; then
echo "Backing up MySQL database using binary backup strategy ..."
else
echo "Backing up MySQL database using logical backup strategy ..."
fi
ghe-backup-mysql || failures="$failures mysql"

commands=("
Expand Down
4 changes: 4 additions & 0 deletions share/github-backup-utils/ghe-backup-config
Original file line number Diff line number Diff line change
Expand Up @@ -381,3 +381,7 @@ fix_paths_for_ghe_version() {
# GHES), then don't modify lines with "gist" in them.
sed $GIST_FILTER -e 's/\/$//; s/^[^\/]*$/./; s/\/[^\/]*$//'
}

is_binary_backup_feature_on(){
ghe-ssh "$GHE_HOSTNAME" ghe-config --true "mysql.backup.binary"
}
5 changes: 0 additions & 5 deletions share/github-backup-utils/ghe-backup-mysql
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@ bm_start "$(basename $0)"
# Perform a host-check and establish the remote version in GHE_REMOTE_VERSION.
ghe_remote_version_required "$GHE_HOSTNAME"

# if we are going to take a binary backup
is_binary_backup_feature_on(){
ghe-ssh "$GHE_HOSTNAME" ghe-config --true "mysql.backup.binary"
}

export_command="ghe-export-mysql"
if ! is_binary_backup_feature_on; then
# binary backup is already compressed
Expand Down
25 changes: 16 additions & 9 deletions share/github-backup-utils/ghe-restore-mysql
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,22 @@ ghe_remote_version_required "$GHE_HOSTNAME"
# The directory holding the snapshot to restore
snapshot_dir="$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT"

# Check if the backup is binary by looking up the sentinel file
# Check if the backup is binary by looking up the sentinel file
is_binary_backup(){
test -f $snapshot_dir/mysql-binary-backup-sentinel
test -f $snapshot_dir/mysql-binary-backup-sentinel
}

# if mysql.backup.binary feature flag is on
is_binary_backup_feature_on(){
ghe-ssh "$GHE_HOSTNAME" ghe-config --true "mysql.backup.binary"
}
if is_binary_backup_feature_on; then
echo "Appliance is configured for binary backups."
else
echo "Appliance is configured for logical backups."
fi

if is_binary_backup; then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is that possible:
The Appliance is configured for binary backups, but Backup being restored is a logical backup?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

echo "Backup being restored is a binary backup."
else
echo "Backup being restored is a logical backup."
fi

ssh_config_file_opt=
if is_binary_backup_feature_on; then
Expand All @@ -59,7 +66,7 @@ if is_binary_backup_feature_on; then
ghe_mysql_master=$GHE_HOSTNAME
fi

# Check if the decompress needed by looking into the sentinel file
# Check if the decompress needed by looking into the sentinel file
# In 2.19.5 we compress the binary backup twice
if [ "$(cat $snapshot_dir/mysql-binary-backup-sentinel)" = "NO_ADDITIONAL_COMPRESSION" ]; then
IMPORT_MYSQL=ghe-import-mysql-xtrabackup
Expand All @@ -73,9 +80,9 @@ if is_binary_backup_feature_on; then
GHE_RESTORE_HOST=$GHE_HOSTNAME
fi
else
# We do not allow to restore binary backup without "mysql.backup.binary" set
# We do not allow to restore binary backup without "mysql.backup.binary" set
if is_binary_backup; then
echo "To restore from a binary backup, you have to set ghe-config \"mysql.backup.binary\" to true" >&2
echo "To restore from a binary backup, you have to set ghe-config \"mysql.backup.binary\" to true" >&2
exit 2
else
# legacy mode
Expand Down