Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
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
16 changes: 14 additions & 2 deletions bin/ghe-restore
Original file line number Diff line number Diff line change
Expand Up @@ -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=("
Expand Down Expand Up @@ -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")
Expand Down
9 changes: 9 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,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"
}
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
20 changes: 5 additions & 15 deletions share/github-backup-utils/ghe-restore-mysql
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down