Skip to content

Commit 1d21dcb

Browse files
Merge branch 'master' into djj/typo-fix
2 parents a44aa3d + 07162bd commit 1d21dcb

File tree

8 files changed

+81
-47
lines changed

8 files changed

+81
-47
lines changed

.github/workflows/main.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ jobs:
1717
run: |
1818
sudo apt-get update -y
1919
sudo apt-get install -y devscripts debhelper moreutils fakeroot jq pigz help2man
20-
wget "https://github.com/koalaman/shellcheck/releases/download/latest/shellcheck-latest.linux.x86_64.tar.xz"
21-
tar --xz -xvf "shellcheck-latest.linux.x86_64.tar.xz"
22-
sudo cp shellcheck-latest/shellcheck /usr/bin/shellcheck
20+
wget "https://github.com/koalaman/shellcheck/releases/download/stable/shellcheck-stable.linux.x86_64.tar.xz"
21+
tar --xz -xvf "shellcheck-stable.linux.x86_64.tar.xz"
22+
sudo cp shellcheck-stable/shellcheck /usr/bin/shellcheck
2323
if: matrix.os != 'macos-latest'
2424
- name: Install Dependencies (macOS)
2525
run: |

bin/ghe-backup

Lines changed: 35 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -54,38 +54,7 @@ export CALLING_SCRIPT="ghe-backup"
5454
# shellcheck source=share/github-backup-utils/ghe-backup-config
5555
. "$( dirname "${BASH_SOURCE[0]}" )/../share/github-backup-utils/ghe-backup-config"
5656

57-
# Setup progress tracking
58-
init-progress
59-
export PROGRESS_TOTAL=14 # Minimum number of steps in backup is 14
60-
echo "$PROGRESS_TOTAL" > /tmp/backup-utils-progress-total
61-
export PROGRESS_TYPE="Backup"
62-
echo "$PROGRESS_TYPE" > /tmp/backup-utils-progress-type
63-
export PROGRESS=0 # Used to track progress of backup
64-
echo "$PROGRESS" > /tmp/backup-utils-progress
65-
66-
OPTIONAL_STEPS=0
67-
# Backup actions+mssql
68-
if ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.actions.enabled'; then
69-
OPTIONAL_STEPS=$((OPTIONAL_STEPS + 2))
70-
fi
71-
72-
# Backup fsck
73-
if [ "$GHE_BACKUP_FSCK" = "yes" ]; then
74-
OPTIONAL_STEPS=$((OPTIONAL_STEPS + 1))
75-
fi
76-
77-
# Backup minio
78-
if ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.minio.enabled'; then
79-
OPTIONAL_STEPS=$((OPTIONAL_STEPS + 1))
80-
fi
8157

82-
# Backup pages
83-
if [ "$GHE_BACKUP_PAGES" != "no" ]; then
84-
OPTIONAL_STEPS=$((OPTIONAL_STEPS + 1))
85-
fi
86-
87-
PROGRESS_TOTAL=$((OPTIONAL_STEPS + PROGRESS_TOTAL)) # Minimum number of steps in backup is 14
88-
echo "$PROGRESS_TOTAL" > /tmp/backup-utils-progress-total
8958
# Check to make sure moreutils parallel is installed and working properly
9059
ghe_parallel_check
9160

@@ -186,9 +155,44 @@ fi
186155
# Perform a host connection check and establish the remote appliance version.
187156
# The version is available in the GHE_REMOTE_VERSION variable and also written
188157
# to a version file in the snapshot directory itself.
158+
# ghe_remote_version_required should be run before any other instances of ghe-ssh
159+
# to ensure that there are no problems with host key verification.
189160
ghe_remote_version_required
190161
echo "$GHE_REMOTE_VERSION" > version
191162

163+
# Setup progress tracking
164+
init-progress
165+
export PROGRESS_TOTAL=14 # Minimum number of steps in backup is 14
166+
echo "$PROGRESS_TOTAL" > /tmp/backup-utils-progress-total
167+
export PROGRESS_TYPE="Backup"
168+
echo "$PROGRESS_TYPE" > /tmp/backup-utils-progress-type
169+
export PROGRESS=0 # Used to track progress of backup
170+
echo "$PROGRESS" > /tmp/backup-utils-progress
171+
172+
OPTIONAL_STEPS=0
173+
# Backup actions+mssql
174+
if ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.actions.enabled'; then
175+
OPTIONAL_STEPS=$((OPTIONAL_STEPS + 2))
176+
fi
177+
178+
# Backup fsck
179+
if [ "$GHE_BACKUP_FSCK" = "yes" ]; then
180+
OPTIONAL_STEPS=$((OPTIONAL_STEPS + 1))
181+
fi
182+
183+
# Backup minio
184+
if ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.minio.enabled'; then
185+
OPTIONAL_STEPS=$((OPTIONAL_STEPS + 1))
186+
fi
187+
188+
# Backup pages
189+
if [ "$GHE_BACKUP_PAGES" != "no" ]; then
190+
OPTIONAL_STEPS=$((OPTIONAL_STEPS + 1))
191+
fi
192+
193+
PROGRESS_TOTAL=$((OPTIONAL_STEPS + PROGRESS_TOTAL)) # Minimum number of steps in backup is 14
194+
echo "$PROGRESS_TOTAL" > /tmp/backup-utils-progress-total
195+
192196
# check that incremental settings are valid if set
193197
is_inc=$(is_incremental_backup_feature_on)
194198

bin/ghe-host-check

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,19 @@ if ghe-ssh "$host" -- \
9191
CLUSTER=true
9292
fi
9393

94-
# ensure all nodes in the cluster are running the same version
94+
# ensure all nodes in the cluster are online/reachable and running the same version
9595
if "$CLUSTER"; then
96+
online_status=$(ghe-ssh "$host" ghe-cluster-host-check)
97+
if [ "$online_status" != "Cluster is ready to configure." ]; then
98+
echo "Error: Not all nodes are online! Please ensure cluster is in a healthy state before using backup-utils." 1>&2
99+
exit 1
100+
fi
101+
96102
node_version_list=$(ghe-ssh "$host" ghe-cluster-each -- ghe-version)
97103
distinct_versions=$(echo "$node_version_list" | awk '{split($0, a, ":"); print a[2]}' | awk '{print $4}' | uniq | wc -l)
98104
if [ "$distinct_versions" -ne 1 ]; then
99-
echo "$node_version_list" 1>&2
100-
echo "Error: Not all nodes are running the same version! Please ensure all nodes are running the same version before using backup-utils." 1>&3
105+
echo "Version mismatch: $node_version_list" 1>&2
106+
echo "Error: Not all nodes are running the same version! Please ensure all nodes are running the same version before using backup-utils." 1>&2
101107
exit 1
102108
fi
103109
fi
@@ -184,15 +190,17 @@ SKIP_MSG
184190
echo " - Recommended Disk requirement is $recommended_disk_req MB" 1>&2
185191
echo "" 1>&2
186192

187-
printf '### Data Transfer Sizes
193+
printf '### Estimated Data Transfer Sizes
194+
188195
- repositories: %d MB
189196
- pages: %d MB
190197
- elasticsearch: %d MB
191198
- storage: %d MB
192199
- minio: %d MB
193200
- mysql: %d MB
194201
- actions: %d MB
195-
- mssql: %d MB\n' \
202+
- mssql: %d MB
203+
\n' \
196204
"$repos_disk_size" "$pages_disk_size" "$es_disk_size" "$stor_disk_size" "$minio_disk_size" "$mysql_disk_size" "$actions_disk_size" "$mssql_disk_size" 1>&2
197205

198206
if [[ $((available_space / (1024 * 1024))) -lt $min_disk_req ]]; then

bin/ghe-restore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -469,13 +469,13 @@ fi
469469

470470
# Always restore column encryption keys
471471
if [ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 3.7.0)" ]; then
472-
log_info "Always restore encrypted column encryption keys on GHES verions 3.7.0+"
472+
log_info "Always restore encrypted column encryption keys on GHES versions 3.7.0+"
473473
fi
474474
ghe-restore-column-encryption-keys "$GHE_HOSTNAME"
475475

476476
# Always restore secret scanning encryption keys
477477
if [ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 3.8.0)" ]; then
478-
log_info "Always restore secret scanning encryption keys on GHES verions 3.8.0+"
478+
log_info "Always restore secret scanning encryption keys on GHES versions 3.8.0+"
479479
increment-progress-total-count 1
480480
ghe-restore-secret-scanning-encryption-keys "$GHE_HOSTNAME"
481481
fi

script/release

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ DEB_PKG_NAME = 'github-backup-utils'
3434
GH_BASE_BRANCH = ENV['GH_BASE_BRANCH'] || 'master' # TODO: should we even allow a default or require all params get set explicitly?
3535
GH_STABLE_BRANCH = ""
3636

37+
# If PUBLISH is false, we leave the release in a draft state to be manually published later through the UI
38+
PUBLISH = ENV['PUBLISH'] == 'true' || false
39+
3740
CHANGELOG_TMPL = '''<%= package_name %> (<%= package_version %>) UNRELEASED; urgency=medium
3841
3942
<%- changes.each do |ch| -%>
@@ -480,15 +483,21 @@ if $PROGRAM_NAME == __FILE__
480483
attach_assets_to_release res['upload_url'], res['id'], ["#{base_dir}/dist/#{DEB_PKG_NAME}-v#{version}.tar.gz"]
481484
attach_assets_to_release res['upload_url'], res['id'], ["#{base_dir}/dist/#{DEB_PKG_NAME}_#{version}_all.deb"]
482485

483-
puts 'Publishing release...'
484-
publish_release res['id']
486+
if PUBLISH
487+
puts 'Publishing release...'
488+
publish_release res['id']
489+
end
485490

486491
puts 'Cleaning up...'
487492
clean_up version
488493

489494
puts "Updating #{GH_STABLE_BRANCH} branch..."
490495
update_stable_branch
491496

497+
if !PUBLISH
498+
puts 'Release left in a "Draft" state. Go to the https://github.com/github/backup-utils/releases and publish when ready.'
499+
end
500+
492501
puts 'Released!'
493502
rescue RuntimeError => e
494503
$stderr.puts "Error: #{e}"

share/github-backup-utils/ghe-backup-mssql

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,9 +335,12 @@ if [ -n "$backup_type" ]; then
335335
elif [ "$backup_type" = "transaction" ]; then
336336
backup_command='ghe-export-mssql -t'
337337
fi
338-
338+
339+
backup_failed=
340+
339341
bm_start "$(basename "$0")"
340-
ghe_ssh_mssql -- "$backup_command"
342+
# record if generating the backup failed, this will allow us to collect any backups that may have been produced, even if they are not complete they are better than nothing
343+
ghe_ssh_mssql -- "$backup_command" || backup_failed='true'
341344
bm_end "$(basename "$0")"
342345

343346
# Configure the backup cadence on the appliance, which is used for diagnostics
@@ -352,4 +355,9 @@ if [ -n "$backup_type" ]; then
352355
ghe_verbose "Transferring to backup host $b"
353356
ghe_ssh_mssql "sudo cat $appliance_dir/$b" > "$backup_dir"/"$b"
354357
done
358+
359+
if [ -n "$backup_failed" ]; then
360+
log_error 'ghe-export-mssql failed to backup at least one mssql database' 1>&2
361+
exit 1
362+
fi
355363
fi

test/bin/ghe-cluster-host-check

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env bash
2+
# Usage: ghe-cluster-host-check
3+
# Emulates a cluster reachability check
4+
set -e
5+
echo "Cluster is ready to configure."

test/test-shellcheck.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ begin_test "shellcheck: reports no errors or warnings"
1111
set -e
1212
# We manually install the latest Shellcheck on Linux builds as other options
1313
# are too old.
14-
if [ -x "$BASE_PATH/shellcheck-latest/shellcheck" ]; then
15-
shellcheck() { "$BASE_PATH/shellcheck-latest/shellcheck" "$@"; }
14+
if [ -x "$BASE_PATH/shellcheck-stable/shellcheck" ]; then
15+
shellcheck() { "$BASE_PATH/shellcheck-stable/shellcheck" "$@"; }
1616
fi
1717

1818
if ! type shellcheck 1>/dev/null 2>&1; then

0 commit comments

Comments
 (0)