Skip to content

Commit 2a89490

Browse files
Merge branch 'master' into ls/remove-old-code
2 parents 2687962 + 9cd5c50 commit 2a89490

File tree

5 files changed

+32
-22
lines changed

5 files changed

+32
-22
lines changed

bin/ghe-backup

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,11 @@ ghe-ssh "$GHE_HOSTNAME" -- 'ghe-export-ssh-host-keys' > ssh-host-keys.tar ||
180180
failures="$failures ssh-host-keys"
181181
bm_end "ghe-export-ssh-host-keys"
182182

183-
echo "Backing up MySQL database ..."
183+
if is_binary_backup_feature_on; then
184+
echo "Backing up MySQL database using binary backup strategy ..."
185+
else
186+
echo "Backing up MySQL database using logical backup strategy ..."
187+
fi
184188
ghe-backup-mysql || failures="$failures mysql"
185189

186190
commands=("

bin/ghe-restore

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,19 @@ if [ -s "$GHE_RESTORE_SNAPSHOT_PATH/uuid" ] && ! $CLUSTER; then
255255
ghe-ssh "$GHE_HOSTNAME" -- "sudo rm -rf /data/user/consul/raft"
256256
fi
257257

258-
echo "Restoring MySQL database ..."
258+
if is_binary_backup_feature_on; then
259+
appliance_strategy="binary"
260+
else
261+
appliance_strategy="logical"
262+
fi
263+
264+
if is_binary_backup "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT"; then
265+
backup_snapshot_strategy="binary"
266+
else
267+
backup_snapshot_strategy="logical"
268+
fi
269+
270+
echo "Restoring MySQL database from ${backup_snapshot_strategy} backup snapshot on an appliance configured for ${appliance_strategy} backups ..."
259271
ghe-restore-mysql "$GHE_HOSTNAME" 1>&3
260272

261273
commands=("

share/github-backup-utils/ghe-backup-config

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,3 +381,12 @@ fix_paths_for_ghe_version() {
381381
# GHES), then don't modify lines with "gist" in them.
382382
sed $GIST_FILTER -e 's/\/$//; s/^[^\/]*$/./; s/\/[^\/]*$//'
383383
}
384+
385+
is_binary_backup_feature_on(){
386+
ghe-ssh "$GHE_HOSTNAME" ghe-config --true "mysql.backup.binary"
387+
}
388+
389+
# Check if the backup is binary by looking up the sentinel file
390+
is_binary_backup(){
391+
test -f "$1/mysql-binary-backup-sentinel"
392+
}

share/github-backup-utils/ghe-backup-mysql

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,6 @@ bm_start "$(basename $0)"
1515
# Perform a host-check and establish the remote version in GHE_REMOTE_VERSION.
1616
ghe_remote_version_required "$GHE_HOSTNAME"
1717

18-
# if we are going to take a binary backup
19-
is_binary_backup_feature_on(){
20-
ghe-ssh "$GHE_HOSTNAME" ghe-config --true "mysql.backup.binary"
21-
}
22-
2318
export_command="ghe-export-mysql"
2419
if ! is_binary_backup_feature_on; then
2520
# binary backup is already compressed

share/github-backup-utils/ghe-restore-mysql

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,10 @@ ghe_remote_version_required "$GHE_HOSTNAME"
2828
# The directory holding the snapshot to restore
2929
snapshot_dir="$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT"
3030

31-
# Check if the backup is binary by looking up the sentinel file
32-
is_binary_backup(){
33-
test -f $snapshot_dir/mysql-binary-backup-sentinel
34-
}
35-
36-
# if mysql.backup.binary feature flag is on
37-
is_binary_backup_feature_on(){
38-
ghe-ssh "$GHE_HOSTNAME" ghe-config --true "mysql.backup.binary"
39-
}
40-
4131
ssh_config_file_opt=
4232
if is_binary_backup_feature_on; then
4333
# Feature "mysql.backup.binary" is on, which means new backup scripts are available
44-
if is_binary_backup; then
34+
if is_binary_backup "$snapshot_dir"; then
4535
if $CLUSTER ; then
4636
ghe_mysql_master=$(ghe-ssh "$GHE_HOSTNAME" ghe-config "cluster.mysql-master")
4737
if [ -z $ghe_mysql_master ]; then
@@ -59,7 +49,7 @@ if is_binary_backup_feature_on; then
5949
ghe_mysql_master=$GHE_HOSTNAME
6050
fi
6151

62-
# Check if the decompress needed by looking into the sentinel file
52+
# Check if the decompress needed by looking into the sentinel file
6353
# In 2.19.5 we compress the binary backup twice
6454
if [ "$(cat $snapshot_dir/mysql-binary-backup-sentinel)" = "NO_ADDITIONAL_COMPRESSION" ]; then
6555
IMPORT_MYSQL=ghe-import-mysql-xtrabackup
@@ -73,9 +63,9 @@ if is_binary_backup_feature_on; then
7363
GHE_RESTORE_HOST=$GHE_HOSTNAME
7464
fi
7565
else
76-
# We do not allow to restore binary backup without "mysql.backup.binary" set
77-
if is_binary_backup; then
78-
echo "To restore from a binary backup, you have to set ghe-config \"mysql.backup.binary\" to true" >&2
66+
# We do not allow to restore binary backup without "mysql.backup.binary" set
67+
if is_binary_backup "$snapshot_dir"; then
68+
echo "To restore from a binary backup, you have to set ghe-config \"mysql.backup.binary\" to true" >&2
7969
exit 2
8070
else
8171
# legacy mode

0 commit comments

Comments
 (0)