Skip to content

Commit c960d8c

Browse files
authored
Don't run incremental backups or restores with versions < 3.10 (#471)
1 parent 56529f9 commit c960d8c

File tree

3 files changed

+32
-6
lines changed

3 files changed

+32
-6
lines changed

bin/ghe-backup

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,10 +187,15 @@ echo "$GHE_REMOTE_VERSION" > version
187187
is_inc=$(is_incremental_backup_feature_on)
188188

189189
if [ "$is_inc" = true ]; then
190-
if [ "$GHE_VERSION_MAJOR" -lt 3 ] && [ "$GHE_VERSION_MINOR" -lt 10 ]; then
191-
log_error "Cannot only perform incremental backups on enterprise version 3.10 or higher"
190+
if [ "$GHE_VERSION_MAJOR" -lt 3 ]; then
191+
log_error "Can only perform incremental backups on enterprise version 3.10 or higher"
192192
exit 1
193193
fi
194+
if [ "$GHE_VERSION_MINOR" -lt 10 ]; then
195+
log_error "Can only perform incremental backups on enterprise version 3.10 or higher"
196+
exit 1
197+
fi
198+
194199
incremental_backup_check
195200
# If everything is ok, check if we have hit GHE_MAX_INCREMENTAL_BACKUPS, performing pruning actions if necessary
196201
check_for_incremental_max_backups

bin/ghe-restore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,14 @@ START_TIME=$(date +%s)
326326
log_info "Starting restore of $GHE_HOSTNAME with backup-utils v$BACKUP_UTILS_VERSION from snapshot $GHE_RESTORE_SNAPSHOT"
327327

328328
if [ "$GHE_INCREMENTAL" ]; then
329+
if [ "$GHE_VERSION_MAJOR" -lt 3 ]; then
330+
log_error "Can only perform incremental restores on enterprise version 3.10 or higher"
331+
exit 1
332+
fi
333+
if [ "$GHE_VERSION_MINOR" -lt 10 ]; then
334+
log_error "Can only perform incremental restores on enterprise version 3.10 or higher"
335+
exit 1
336+
fi
329337
log_info "Incremental restore from snapshot $GHE_RESTORE_SNAPSHOT"
330338
# If we see 'inc_previous' prepended to the snapshot name, then
331339
# we set $INC_FULL_BACKUP and $INC_SNAPSHOT_DATA to $INC_PREVIOUS_FULL_BACKUP and

test/test-ghe-backup.sh

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ begin_test "ghe-backup incremental"
6262

6363
# run it
6464
# this time expect full backup
65-
ghe-backup -i
65+
GHE_TEST_REMOTE_VERSION=3.10.0 ghe-backup -i
6666

6767
# check metadata files are created
6868
[ -e "$GHE_DATA_DIR/inc_full_backup" ]
@@ -77,7 +77,7 @@ begin_test "ghe-backup incremental"
7777

7878
# re-run
7979
# this time expect incremental backup
80-
ghe-backup -i
80+
GHE_TEST_REMOTE_VERSION=3.10.0 ghe-backup -i
8181

8282
expected_full_backup=$(wc -l < "$GHE_DATA_DIR/inc_full_backup")
8383
expected_incremental_backup=$(wc -l < "$GHE_DATA_DIR/inc_snapshot_data")
@@ -87,7 +87,7 @@ begin_test "ghe-backup incremental"
8787

8888
# re-run
8989
# this time expect yet another incremental backup
90-
ghe-backup -i
90+
GHE_TEST_REMOTE_VERSION=3.10.0 ghe-backup -i
9191

9292
expected_full_backup=$(wc -l < "$GHE_DATA_DIR/inc_full_backup")
9393
expected_incremental_backup=$(wc -l < "$GHE_DATA_DIR/inc_snapshot_data")
@@ -107,10 +107,23 @@ begin_test "ghe-backup incremental without config"
107107
export GHE_INCREMENTAL_MAX_BACKUPS=1
108108

109109
# check ghe-backup fails
110-
! ghe-backup -i
110+
! GHE_TEST_REMOTE_VERSION=3.10.0 ghe-backup -i
111111
)
112112
end_test
113113

114+
begin_test "ghe-backup performs proper version check"
115+
(
116+
set -e
117+
sleep 1
118+
119+
setup_incremental_backup_config
120+
121+
#check ghe-backup fails
122+
! GHE_TEST_REMOTE_VERSION=3.9.0 ghe-backup -i
123+
! GHE_TEST_REMOTE_VERSION=3.8.0 ghe-backup -i
124+
! GHE_TEST_REMOTE_VERSION=2.2.0 ghe_backup -i
125+
)
126+
114127
begin_test "ghe-backup logs the benchmark"
115128
(
116129
set -e

0 commit comments

Comments
 (0)