Skip to content

Commit c7deec0

Browse files
committed
Merge remote-tracking branch 'private/enterprise-3.9-release' into 3.9.2-patch
2 parents d2f4e83 + 1405e49 commit c7deec0

23 files changed

+275
-62
lines changed

Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ RUN apt-get update && apt-get install --no-install-recommends -y \
2626
libssl-dev \
2727
git \
2828
jq \
29+
bc \
2930
curl \
3031
tar \
3132
gzip \
@@ -54,8 +55,9 @@ RUN apt-get update && apt-get install --no-install-recommends -y \
5455
git \
5556
openssh-client \
5657
jq \
58+
bc \
5759
moreutils \
58-
gawk \
60+
gawk \
5961
ca-certificates \
6062
xxhash \
6163
&& rm -rf /var/lib/apt/lists/*

backup.config-example

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ GHE_DATA_DIR="data"
1616
# be available for the past N days ...
1717
GHE_NUM_SNAPSHOTS=10
1818

19+
# If GHE_SKIP_CHECKS is set to true (or if --skip-checks is used with ghe-backup) then ghe-host-check
20+
# disk space validation and software version checks on the backup-host will be disabled.
21+
#GHE_SKIP_CHECKS=false
22+
1923
# The hostname of the GitHub appliance to restore. If you've set up a separate
2024
# GitHub appliance to act as a standby for recovery, specify its IP or hostname
2125
# here. The host to restore to may also be specified directly when running

bin/ghe-backup

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@
55
#/ the MySQL database, instance settings, GitHub Pages data, etc.
66
#/
77
#/ OPTIONS:
8-
#/ -v | --verbose Enable verbose output.
9-
#/ -h | --help Show this message.
10-
#/ --version Display version information.
8+
#/ -v | --verbose Enable verbose output.
9+
#/ -h | --help Show this message.
10+
#/ --version Display version information.
11+
#/ --skip-checks Skip storage/sw version checks
1112
#/
1213

1314
set -e
@@ -27,6 +28,10 @@ while true; do
2728
export GHE_VERBOSE=true
2829
shift
2930
;;
31+
--skip-checks)
32+
export GHE_SKIP_CHECKS=true
33+
shift
34+
;;
3035
-*)
3136
echo "Error: invalid argument: '$1'" 1>&2
3237
exit 1
@@ -46,12 +51,36 @@ export CALLING_SCRIPT="ghe-backup"
4651

4752
# Setup progress tracking
4853
init-progress
54+
export PROGRESS_TOTAL=14 # Minimum number of steps in backup is 14
55+
echo "$PROGRESS_TOTAL" > /tmp/backup-utils-progress-total
4956
export PROGRESS_TYPE="Backup"
5057
echo "$PROGRESS_TYPE" > /tmp/backup-utils-progress-type
5158
export PROGRESS=0 # Used to track progress of backup
5259
echo "$PROGRESS" > /tmp/backup-utils-progress
53-
export PROGRESS_TOTAL=18 # Maximum number of steps in backup
5460

61+
OPTIONAL_STEPS=0
62+
# Backup actions+mssql
63+
if ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.actions.enabled'; then
64+
OPTIONAL_STEPS=$((OPTIONAL_STEPS + 2))
65+
fi
66+
67+
# Backup fsck
68+
if [ "$GHE_BACKUP_FSCK" = "yes" ]; then
69+
OPTIONAL_STEPS=$((OPTIONAL_STEPS + 1))
70+
fi
71+
72+
# Backup minio
73+
if ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.minio.enabled'; then
74+
OPTIONAL_STEPS=$((OPTIONAL_STEPS + 1))
75+
fi
76+
77+
# Backup pages
78+
if [ "$GHE_BACKUP_PAGES" != "no" ]; then
79+
OPTIONAL_STEPS=$((OPTIONAL_STEPS + 1))
80+
fi
81+
82+
PROGRESS_TOTAL=$((OPTIONAL_STEPS + PROGRESS_TOTAL)) # Minimum number of steps in backup is 14
83+
echo "$PROGRESS_TOTAL" > /tmp/backup-utils-progress-total
5584
# Check to make sure moreutils parallel is installed and working properly
5685
ghe_parallel_check
5786

@@ -269,6 +298,7 @@ echo \"$cmd_title\"
269298
ghe-backup-git-hooks || printf %s \"git-hooks \" >> \"$failures_file\"")
270299

271300
if [ "$GHE_BACKUP_STRATEGY" = "rsync" ]; then
301+
increment-progress-total-count 1
272302
cmd_title=$(log_info "Backing up Elasticsearch indices ...")
273303
commands+=("
274304
echo \"$cmd_title\"
@@ -303,6 +333,8 @@ if [ -z "$failures" ]; then
303333
ln -s "$GHE_SNAPSHOT_TIMESTAMP" "../current"
304334

305335
ghe-prune-snapshots
336+
else
337+
log_info "Skipping pruning snapshots, since some backups failed..."
306338
fi
307339

308340
END_TIME=$(date +%s)

bin/ghe-host-check

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,13 @@ if [ -z "$supported" ]; then
144144
exit 1
145145
fi
146146

147-
if [[ "$CALLING_SCRIPT" == "ghe-backup" ]]; then
147+
if [[ "$CALLING_SCRIPT" == "ghe-backup" && "$GHE_SKIP_CHECKS" != "true" ]]; then
148+
cat << SKIP_MSG 1>&2
149+
**You can disable the following storage & version checks by running ghe-backup with option "--skip-checks"
150+
OR updating GHE_SKIP_CHECKS to 'true' in your backup.config file.
151+
152+
SKIP_MSG
153+
148154
# Bring in the requirements file
149155
min_rsync=""
150156
min_openssh=""
@@ -184,6 +190,7 @@ minio: $minio_disk_size MB
184190
mysql: $mysql_disk_size MB
185191
actions: $actions_disk_size MB
186192
mssql: $mssql_disk_size MB
193+
187194
DATA_TRANSFER_SIZE
188195

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

bin/ghe-restore

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -275,17 +275,14 @@ fi
275275
# taking into account the options passed to the script and the appliance configuration
276276
# calculate restore steps
277277
OPTIONAL_STEPS=0
278-
# Cluster restores add an additional step
279-
if $CLUSTER ; then
280-
OPTIONAL_STEPS=$((OPTIONAL_STEPS + 1))
281-
fi
278+
282279
# Restoring UUID
283280
if [ -s "$GHE_RESTORE_SNAPSHOT_PATH/uuid" ] && ! $CLUSTER; then
284281
OPTIONAL_STEPS=$((OPTIONAL_STEPS + 1))
285282
fi
286-
# Restoring Actions
283+
# Restoring Actions + MSSQL
287284
if ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.actions.enabled'; then
288-
OPTIONAL_STEPS=$((OPTIONAL_STEPS + 1))
285+
OPTIONAL_STEPS=$((OPTIONAL_STEPS + 2))
289286
fi
290287
# Restoring minio
291288
if ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.minio.enabled'; then
@@ -305,10 +302,16 @@ fi
305302
if ! $CLUSTER && $instance_configured; then
306303
OPTIONAL_STEPS=$((OPTIONAL_STEPS + 1))
307304
fi
308-
# Maximum restore steps
309-
export PROGRESS_TOTAL=$((OPTIONAL_STEPS + 6))
305+
# Restoring settings + restore-chat-integration + restore-packages
306+
if $RESTORE_SETTINGS; then
307+
OPTIONAL_STEPS=$((OPTIONAL_STEPS + 3))
308+
fi
309+
310+
# Minimum number of steps is 7
311+
export PROGRESS_TOTAL=$((OPTIONAL_STEPS + 7))
310312

311313
init-progress
314+
echo "$PROGRESS_TOTAL" > /tmp/backup-utils-progress-total
312315
export PROGRESS_TYPE="Restore"
313316
echo "$PROGRESS_TYPE" > /tmp/backup-utils-progress-type
314317
export PROGRESS=0 # Used to track progress of restore
@@ -443,6 +446,12 @@ if [ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 3.7.0)" ]; then
443446
fi
444447
ghe-restore-column-encryption-keys "$GHE_HOSTNAME"
445448

449+
# Always restore secret scanning encryption keys
450+
if [ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 3.8.0)" ]; then
451+
log_info "Always restore secret scanning encryption keys on GHES verions 3.8.0+"
452+
ghe-restore-secret-scanning-encryption-keys "$GHE_HOSTNAME"
453+
fi
454+
446455
# Make sure mysql and elasticsearch are prep'd and running before restoring.
447456
# These services will not have been started on appliances that have not been
448457
# configured yet.
@@ -484,6 +493,7 @@ if is_external_database_target_or_snapshot && $SKIP_MYSQL; then
484493
log_info "Skipping MySQL restore."
485494
else
486495
log_info "Restoring MySQL database from ${backup_snapshot_strategy} backup snapshot on an appliance configured for ${appliance_strategy} backups ..."
496+
increment-progress-total-count 2
487497
ghe-restore-mysql "$GHE_HOSTNAME" 1>&3
488498
fi
489499

docs/usage.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,18 @@ appliance at IP "5.5.5.5":
7373
Restore of 5.5.5.5:122 from snapshot 20180326T020444 finished.
7474
To complete the restore process, please visit https://5.5.5.5/setup/settings to review and save the appliance configuration.
7575

76-
A different backup snapshot may be selected by passing the `-s` argument and the
77-
datestamp-named directory from the backup location.
76+
A different backup snapshot may be selected by passing the `-s` argument to `ghe-restore` and specifying the
77+
datestamp-named directory from the backup location as the value.
7878

7979
The `ghe-backup` and `ghe-restore` commands also have a verbose output mode
8080
(`-v`) that lists files as they're being transferred. It's often useful to
8181
enable when output is logged to a file.
8282

83+
Every time you execute `ghe-backup` we verify the storage and software setup of the host
84+
you [installed][1] Backup Utilities on, to make sure our [requirements][2] for the host are
85+
met. You can disable this check using the `--skip-checks` argument or by
86+
adding `GHE_SKIP_CHECKS=true` to your configuration file.
87+
8388
### Restoring settings, TLS certificate, and license
8489

8590
When restoring to a new GitHub Enterprise Server instance, settings, certificate, and
@@ -107,3 +112,4 @@ GitHub Actions enabled, the following steps are required:
107112
Please refer to [GHES Documentation](https://docs.github.com/en/enterprise-server/admin/github-actions/advanced-configuration-and-troubleshooting/backing-up-and-restoring-github-enterprise-server-with-github-actions-enabled) for more details.
108113

109114
[1]: https://github.com/github/backup-utils/blob/master/docs/getting-started.md
115+
[2]: requirements.md

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-config

Lines changed: 7 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ if [ -n "$GHE_SHOW_VERSION" ]; then
3535
fi
3636

3737
# Check for "--help|-h" in args or GHE_SHOW_HELP=true and show usage
38-
# shellcheck disable=SC2120 # the script name is always referenced
38+
# shellcheck disable=SC2120 # Our arguments are optional and not meant to be the owning script's
3939
print_usage() {
4040
grep '^#/' <"$0" | cut -c 4-
4141
exit "${1:-1}"
@@ -51,10 +51,6 @@ else
5151
done
5252
fi
5353

54-
# Add the bin and share/github-backup-utils dirs to PATH
55-
PATH="$GHE_BACKUP_ROOT/bin:$GHE_BACKUP_ROOT/share/github-backup-utils:$PATH"
56-
# shellcheck source=share/github-backup-utils/bm.sh
57-
. "$GHE_BACKUP_ROOT/share/github-backup-utils/bm.sh"
5854
# Save off GHE_HOSTNAME from the environment since we want it to override the
5955
# backup.config value when set.
6056
GHE_HOSTNAME_PRESERVE="$GHE_HOSTNAME"
@@ -150,44 +146,12 @@ log_ssh(){
150146
log_level "ssh" "$1"
151147
}
152148

153-
# Assume this script lives in share/github-backup-utils/ when setting the root
154-
GHE_BACKUP_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
155-
156-
# Get the version from the version file.
157-
BACKUP_UTILS_VERSION="$(cat "$GHE_BACKUP_ROOT/share/github-backup-utils/version")"
158-
159-
# If a version check was requested, show the current version and exit
160-
if [ -n "$GHE_SHOW_VERSION" ]; then
161-
echo "GitHub backup-utils v$BACKUP_UTILS_VERSION"
162-
exit 0
163-
fi
164-
165-
# Check for "--help|-h" in args or GHE_SHOW_HELP=true and show usage
166-
# shellcheck disable=SC2120 # Our arguments are optional and not meant to be the owning script's
167-
print_usage() {
168-
grep '^#/' <"$0" | cut -c 4-
169-
exit "${1:-1}"
170-
}
171-
172-
if [ -n "$GHE_SHOW_HELP" ]; then
173-
print_usage
174-
else
175-
for a in "$@"; do
176-
if [ "$a" = "--help" ] || [ "$a" = "-h" ]; then
177-
print_usage
178-
fi
179-
done
180-
fi
181-
182149
# Add the bin and share/github-backup-utils dirs to PATH
183150
PATH="$GHE_BACKUP_ROOT/bin:$GHE_BACKUP_ROOT/share/github-backup-utils:$PATH"
184151
# shellcheck source=share/github-backup-utils/bm.sh
185152
. "$GHE_BACKUP_ROOT/share/github-backup-utils/bm.sh"
186153
# shellcheck source=share/github-backup-utils/track-progress
187154
. "$GHE_BACKUP_ROOT/share/github-backup-utils/track-progress"
188-
# Save off GHE_HOSTNAME from the environment since we want it to override the
189-
# backup.config value when set.
190-
GHE_HOSTNAME_PRESERVE="$GHE_HOSTNAME"
191155

192156
# Source in the backup config file from the copy specified in the environment
193157
# first and then fall back to the backup-utils root, home directory and system.
@@ -712,6 +676,12 @@ init-progress() {
712676
rm -f /tmp/backup-utils-progress*
713677
}
714678

679+
#increase total count of progress
680+
increment-progress-total-count() {
681+
((PROGRESS_TOTAL += $1))
682+
echo "$PROGRESS_TOTAL" > /tmp/backup-utils-progress-total
683+
}
684+
715685

716686

717687

share/github-backup-utils/ghe-backup-es-rsync

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#/
55
#/ Note: This command typically isn't called directly. It's invoked by
66
#/ ghe-backup when the rsync strategy is used.
7+
# shellcheck disable=SC2086
78
set -e
89

910
# Bring in the backup configuration
@@ -54,15 +55,15 @@ log_rsync "END elasticsearch rsync" 1>&3
5455
# Set up a trap to re-enable flushing on exit and remove temp file
5556
cleanup () {
5657
ghe_verbose "* Enabling ES index flushing ..."
57-
echo '{"index":{"translog.disable_flush":false}}' |
58+
echo '{"index":{"translog.flush_threshold_size":"512MB"}}' |
5859
ghe-ssh "$host" -- curl -s -XPUT "localhost:9200/_settings" -d @- >/dev/null
5960
}
6061
trap 'cleanup' EXIT
6162
trap 'exit $?' INT # ^C always terminate
6263

6364
# Disable ES flushing and force a flush right now
6465
ghe_verbose "* Disabling ES index flushing ..."
65-
echo '{"index":{"translog.disable_flush":true}}' |
66+
echo '{"index":{"translog.flush_threshold_size":"1PB"}}' |
6667
ghe-ssh "$host" -- curl -s -XPUT "localhost:9200/_settings" -d @- >/dev/null
6768
ghe-ssh "$host" -- curl -s -XPOST "localhost:9200/_flush" >/dev/null
6869

share/github-backup-utils/ghe-backup-pages

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ if [ -d "$GHE_DATA_DIR/current/pages" ] && [ "$(ls -A $GHE_DATA_DIR/current/page
6363
link_dest="--link-dest=../../current/pages"
6464
fi
6565

66+
count=0
6667
for hostname in $hostnames; do
6768
bm_start "$(basename $0) - $hostname"
6869
echo 1>&3
@@ -82,6 +83,7 @@ for hostname in $hostnames; do
8283
"$GHE_SNAPSHOT_DIR/pages" 1>&3
8384
log_rsync "END: pages rsync" 1>&3
8485
bm_end "$(basename $0) - $hostname"
86+
count=$((count + 1))
8587
done
86-
88+
increment-progress-total-count $count
8789
bm_end "$(basename $0)"

0 commit comments

Comments
 (0)