diff --git a/bin/ghe-backup b/bin/ghe-backup index e45817727..3763aa5bf 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -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=(" diff --git a/bin/ghe-restore b/bin/ghe-restore index e9089da3a..c891793d7 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -255,7 +255,19 @@ if [ -s "$GHE_RESTORE_SNAPSHOT_PATH/uuid" ] && ! $CLUSTER; then ghe-ssh "$GHE_HOSTNAME" -- "sudo rm -rf /data/user/consul/raft" fi -echo "Restoring MySQL database ..." +if is_binary_backup_feature_on; then + appliance_strategy="binary" +else + appliance_strategy="logical" +fi + +if is_binary_backup "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT"; then + backup_snapshot_strategy="binary" +else + backup_snapshot_strategy="logical" +fi + +echo "Restoring MySQL database from ${backup_snapshot_strategy} backup snapshot on an appliance configured for ${appliance_strategy} backups ..." ghe-restore-mysql "$GHE_HOSTNAME" 1>&3 commands=(" @@ -318,7 +330,7 @@ if $CLUSTER || [ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 2.12.9)" ]; the echo \"Restoring Audit logs ...\" ghe-restore-es-audit-log \"$GHE_HOSTNAME\" 1>&3") fi - + commands+=(" echo \"Restoring hookshot logs ...\" ghe-restore-es-hookshot \"$GHE_HOSTNAME\" 1>&3") diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 8b0d1d4bf..176ecdc17 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -381,3 +381,12 @@ 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" +} + +# Check if the backup is binary by looking up the sentinel file +is_binary_backup(){ + test -f "$1/mysql-binary-backup-sentinel" +} \ No newline at end of file diff --git a/share/github-backup-utils/ghe-backup-mysql b/share/github-backup-utils/ghe-backup-mysql index 983341461..6148fd2d5 100755 --- a/share/github-backup-utils/ghe-backup-mysql +++ b/share/github-backup-utils/ghe-backup-mysql @@ -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 diff --git a/share/github-backup-utils/ghe-restore-mysql b/share/github-backup-utils/ghe-restore-mysql index 150c93a77..81189f059 100755 --- a/share/github-backup-utils/ghe-restore-mysql +++ b/share/github-backup-utils/ghe-restore-mysql @@ -28,20 +28,10 @@ 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 -is_binary_backup(){ - 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" -} - ssh_config_file_opt= if is_binary_backup_feature_on; then # Feature "mysql.backup.binary" is on, which means new backup scripts are available - if is_binary_backup; then + if is_binary_backup "$snapshot_dir"; then if $CLUSTER ; then ghe_mysql_master=$(ghe-ssh "$GHE_HOSTNAME" ghe-config "cluster.mysql-master") if [ -z $ghe_mysql_master ]; then @@ -59,7 +49,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 @@ -73,9 +63,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 - if is_binary_backup; then - echo "To restore from a binary backup, you have to set ghe-config \"mysql.backup.binary\" to true" >&2 + # We do not allow to restore binary backup without "mysql.backup.binary" set + if is_binary_backup "$snapshot_dir"; then + echo "To restore from a binary backup, you have to set ghe-config \"mysql.backup.binary\" to true" >&2 exit 2 else # legacy mode