Skip to content

Commit 850d912

Browse files
authored
Merge pull request #1099 from github/3.7.2-patch
3.7.2 patch
2 parents a7767f3 + c2e0977 commit 850d912

File tree

8 files changed

+43
-19
lines changed

8 files changed

+43
-19
lines changed

.github/workflows/main.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ jobs:
1414
run: |
1515
sudo apt-get update -y
1616
sudo apt-get install -y devscripts debhelper moreutils fakeroot jq pigz help2man
17-
wget "https://github.com/koalaman/shellcheck/releases/download/latest/shellcheck-latest.linux.x86_64.tar.xz"
18-
tar --xz -xvf "shellcheck-latest.linux.x86_64.tar.xz"
19-
sudo cp shellcheck-latest/shellcheck /usr/bin/shellcheck
17+
wget "https://github.com/koalaman/shellcheck/releases/download/stable/shellcheck-stable.linux.x86_64.tar.xz"
18+
tar --xz -xvf "shellcheck-stable.linux.x86_64.tar.xz"
19+
sudo cp shellcheck-stable/shellcheck /usr/bin/shellcheck
2020
if: matrix.os != 'macos-latest'
2121
- name: Install Dependencies (macOS)
2222
run: |

backup.config-example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,3 +90,6 @@ GHE_NUM_SNAPSHOTS=10
9090
# When running an external mysql database, run this script to trigger a MySQL restore
9191
# rather than attempting to backup via backup-utils directly.
9292
#EXTERNAL_DATABASE_RESTORE_SCRIPT="/bin/false"
93+
94+
# If set to 'yes', Pages data will be included in backup and restore. Defaults to 'yes'
95+
#GHE_BACKUP_PAGES=no

bin/ghe-backup

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -231,9 +231,14 @@ commands+=("
231231
echo \"Backing up Git repositories ...\"
232232
ghe-backup-repositories || printf %s \"repositories \" >> \"$failures_file\"")
233233

234-
commands+=("
235-
echo \"Backing up GitHub Pages artifacts ...\"
236-
ghe-backup-pages || printf %s \"pages \" >> \"$failures_file\"")
234+
# Pages backups are skipped only if GHE_BACKUP_PAGES is explicitly set to 'no' to guarantee backward compatibility.
235+
# If a customer upgrades backup-utils but keeps the config file from a previous version, Pages backups still work as expected.
236+
237+
if [ "$GHE_BACKUP_PAGES" != "no" ]; then
238+
commands+=("
239+
echo \"Backing up GitHub Pages artifacts ...\"
240+
ghe-backup-pages || printf %s \"pages \" >> \"$failures_file\"")
241+
fi
237242

238243
commands+=("
239244
echo \"Backing up storage data ...\"

bin/ghe-restore

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -447,9 +447,11 @@ commands+=("
447447
echo \"Restoring Gists ...\"
448448
ghe-restore-repositories-gist \"$GHE_HOSTNAME\"")
449449

450-
commands+=("
451-
echo \"Restoring GitHub Pages artifacts ...\"
452-
ghe-restore-pages \"$GHE_HOSTNAME\" 1>&3")
450+
if [ "$GHE_BACKUP_PAGES" != "no" ]; then
451+
commands+=("
452+
echo \"Restoring GitHub Pages artifacts ...\"
453+
ghe-restore-pages \"$GHE_HOSTNAME\" 1>&3")
454+
fi
453455

454456
commands+=("
455457
echo \"Restoring SSH authorized keys ...\"

script/release

Lines changed: 12 additions & 3 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| -%>
@@ -332,7 +335,7 @@ def clean_up(version)
332335
`git pull --quiet origin #{GH_BASE_BRANCH} --prune`
333336
`git branch --quiet -D release-#{version} >/dev/null 2>&1`
334337
`git push --quiet origin :release-#{version} >/dev/null 2>&1`
335-
`git branch --quiet -D tmp-packging >/dev/null 2>&1`
338+
`git branch --quiet -D tmp-packaging >/dev/null 2>&1`
336339
end
337340

338341
def is_base_branch_valid?(branch)
@@ -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-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
@@ -53,15 +54,15 @@ ghe-rsync -avz \
5354
# Set up a trap to re-enable flushing on exit and remove temp file
5455
cleanup () {
5556
ghe_verbose "* Enabling ES index flushing ..."
56-
echo '{"index":{"translog.disable_flush":false}}' |
57+
echo '{"index":{"translog.flush_threshold_size":"512MB"}}' |
5758
ghe-ssh "$host" -- curl -s -XPUT "localhost:9200/_settings" -d @- >/dev/null
5859
}
5960
trap 'cleanup' EXIT
6061
trap 'exit $?' INT # ^C always terminate
6162

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

test/test-ghe-host-check.sh

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,14 @@ begin_test "ghe-host-check detects unsupported GitHub Enterprise Server versions
5656
read -r bu_version_major bu_version_minor _ <<<$(ghe_parse_version $BACKUP_UTILS_VERSION)
5757
bu_major_minor="$bu_version_major.$bu_version_minor"
5858
releases=$(/usr/bin/curl -s https://github-enterprise.s3.amazonaws.com/release/latest.json)
59-
supported=$(echo $releases | jq -r 'select(."'${bu_major_minor}'")')
59+
latest_value=$(echo "$releases" | jq -r '.latest')
60+
latest_major_version=$(echo $latest_value | cut -d "." -f 1-2)
61+
# Replace "latest" with the derived major version in the releases string
62+
releases_with_replacement=$(echo "$releases" | sed 's/"latest"/"'"$latest_major_version"'"/g')
63+
# Use the modified releases string as needed
64+
supported=$(echo "$releases_with_replacement" | jq -r 'select(."'${bu_major_minor}'")')
6065
# shellcheck disable=SC2207 # Command required as alternatives fail
61-
keys=($(echo $releases | jq -r 'keys[]'))
66+
keys=($(echo "$releases_with_replacement" | jq -r 'keys[]'))
6267

6368
if [ -z "$supported" ]
6469
then
@@ -87,7 +92,6 @@ begin_test "ghe-host-check detects unsupported GitHub Enterprise Server versions
8792
GHE_TEST_REMOTE_VERSION=$bu_version_major.$bu_version_minor.999gm1 ghe-host-check
8893
! GHE_TEST_REMOTE_VERSION=3.9999.1521793591.performancetest ghe-host-check
8994
GHE_TEST_REMOTE_VERSION=$((bu_version_major+1)).0.0 ghe-host-check
90-
9195
)
9296
end_test
9397

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)