Skip to content

Commit 6b63b4a

Browse files
committed
Merge branch 'master' into hao/backoff-restore-gist
2 parents 648967c + 5fdfcb8 commit 6b63b4a

17 files changed

+293
-65
lines changed

.github/pull_request_template.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# PR Details
2+
3+
### Description
4+
<!--
5+
[Please fill out a brief description of the change being made]
6+
-->
7+
### Testing
8+
<!--
9+
[Please add testing done as part of this change.]
10+
-->
11+
<!-- Keep in mind that for backup-utils the following applies:
12+
- Backup-util [current version] will support
13+
- GHES [current version]
14+
- GHES [current version -1]
15+
- GHES [current version -2]
16+
- Any changes that are made to backup-utils will also need to be supported on those GHES versions above (n-2)
17+
- Please make sure those versions are tested against for this change
18+
-->
19+
20+
### Ownership
21+
<!-- [Add any relevants owners for this change]
22+
-->
23+
24+
### Related Links
25+
<!-- [Please add any related links/issues to this PR]
26+
-->
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Build and Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: 'Version - patch version of the release (e.g. x.y.z)'
8+
required: true
9+
type: string
10+
release-notes:
11+
description: 'Release Notes - string of markdown'
12+
required: true
13+
type: string
14+
draft:
15+
description: 'Draft - true if the release should be a draft'
16+
required: true
17+
type: boolean
18+
default: true
19+
20+
jobs:
21+
build:
22+
runs-on: ubuntu-latest
23+
steps:
24+
- name: Install dependencies
25+
run: |
26+
sudo apt-get update
27+
sudo apt-get install -y moreutils debhelper help2man
28+
- name: Create tag
29+
run: |
30+
git tag -a v${{ github.event.inputs.version }} -m "v${{ github.event.inputs.version }}"
31+
- name: Checkout
32+
uses: actions/checkout@v2
33+
- name: Package deb
34+
run: |
35+
bash scripts/package-deb
36+
- name: Package tarball
37+
run: |
38+
bash scripts/package-tarball
39+
release:
40+
needs: build
41+
runs-on: ubuntu-latest
42+
steps:
43+
- name: Create Release
44+
uses: ncipollo/release-action@v1
45+
with:
46+
repo: github/backup-utils
47+
artifacts: |
48+
./dist/github-backup-utils-v${{ github.event.inputs.version }}.tar.gz
49+
./dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb
50+
# token: ${{ secrets.GITHUB_TOKEN }} may need token, but try without first
51+
name: v${{ github.event.inputs.version }}
52+
draft: ${{ github.event.inputs.draft }}
53+
body: ${{ github.event.inputs.release-notes }}

.github/workflows/main.yml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ jobs:
66
build:
77
strategy:
88
matrix:
9-
# macos-latest references are kept here for historical purposes. removed macos-latest from the
10-
#matrix as it is not a typical case for users and causes a lot of friction with other linux-based
11-
# installs. Recommend developing on codespaces or using an ubuntu container.
129
os: ['ubuntu-22.04', 'ubuntu-20.04']
1310
fail-fast: false
1411
runs-on: ${{ matrix.os }}
@@ -20,12 +17,6 @@ jobs:
2017
wget "https://github.com/koalaman/shellcheck/releases/download/stable/shellcheck-stable.linux.x86_64.tar.xz"
2118
tar --xz -xvf "shellcheck-stable.linux.x86_64.tar.xz"
2219
sudo cp shellcheck-stable/shellcheck /usr/bin/shellcheck
23-
if: matrix.os != 'macos-latest'
24-
- name: Install Dependencies (macOS)
25-
run: |
26-
brew install gnu-tar shellcheck jq pigz coreutils gnu-sed gnu-getopt wget
27-
brew install moreutils gawk
28-
if: matrix.os == 'macos-latest'
2920
- name: Get Sources
3021
uses: actions/checkout@v3
3122
- name: Test
@@ -35,4 +26,3 @@ jobs:
3526
shell: bash
3627
- name: Build (Linux)
3728
run: DEB_BUILD_OPTIONS=nocheck debuild -us -uc
38-
if: matrix.os != 'macos-latest'

bin/ghe-backup

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@ cleanup () {
121121

122122
# Cleanup SSH multiplexing
123123
ghe-ssh --clean
124+
125+
bm_end "$(basename $0)"
124126
}
125127

126128
# Setup exit traps
@@ -163,11 +165,11 @@ echo "$GHE_REMOTE_VERSION" > version
163165
# Setup progress tracking
164166
init-progress
165167
export PROGRESS_TOTAL=14 # Minimum number of steps in backup is 14
166-
echo "$PROGRESS_TOTAL" > /tmp/backup-utils-progress-total
168+
echo "$PROGRESS_TOTAL" > /tmp/backup-utils-progress/total
167169
export PROGRESS_TYPE="Backup"
168-
echo "$PROGRESS_TYPE" > /tmp/backup-utils-progress-type
170+
echo "$PROGRESS_TYPE" > /tmp/backup-utils-progress/type
169171
export PROGRESS=0 # Used to track progress of backup
170-
echo "$PROGRESS" > /tmp/backup-utils-progress
172+
echo "$PROGRESS" > /tmp/backup-utils-progress/progress
171173

172174
OPTIONAL_STEPS=0
173175
# Backup actions+mssql
@@ -191,7 +193,7 @@ if [ "$GHE_BACKUP_PAGES" != "no" ]; then
191193
fi
192194

193195
PROGRESS_TOTAL=$((OPTIONAL_STEPS + PROGRESS_TOTAL)) # Minimum number of steps in backup is 14
194-
echo "$PROGRESS_TOTAL" > /tmp/backup-utils-progress-total
196+
echo "$PROGRESS_TOTAL" > /tmp/backup-utils-progress/total
195197

196198
# check that incremental settings are valid if set
197199
is_inc=$(is_incremental_backup_feature_on)
@@ -216,6 +218,7 @@ fi
216218
echo "$GHE_SNAPSHOT_TIMESTAMP $$" > ../in-progress
217219
echo "$GHE_SNAPSHOT_TIMESTAMP $$" > "${GHE_DATA_DIR}/in-progress-backup"
218220

221+
bm_start "$(basename $0)"
219222
START_TIME=$(date +%s)
220223
log_info "Starting backup of $GHE_HOSTNAME with backup-utils v$BACKUP_UTILS_VERSION in snapshot $GHE_SNAPSHOT_TIMESTAMP"
221224

bin/ghe-backup-progress

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,26 +31,26 @@ while true; do
3131
done
3232

3333
check_for_progress_file() {
34-
if [ ! -f /tmp/backup-utils-progress-info ]; then
34+
if [ ! -f /tmp/backup-utils-progress/info ]; then
3535
echo "No progress file found. Has a backup or restore been started?"
3636
exit 1
3737
fi
3838
}
3939

4040
if [ -n "$ONCE" ]; then
4141
check_for_progress_file
42-
cat /tmp/backup-utils-progress-info
42+
cat /tmp/backup-utils-progress/info
4343
else
4444
check_for_progress_file
4545
clear
46-
cat /tmp/backup-utils-progress-info
46+
cat /tmp/backup-utils-progress/info
4747
while true; do
4848
if read -r -t 1 -n 1; then
4949
clear
5050
exit ;
5151
else
5252
clear
53-
cat /tmp/backup-utils-progress-info
53+
cat /tmp/backup-utils-progress/info
5454
fi
5555
done
5656
fi

bin/ghe-host-check

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,13 @@ SKIP_MSG
168168
# shellcheck source=share/github-backup-utils/ghe-rsync-size
169169
. "$(dirname "${BASH_SOURCE[0]}")/../share/github-backup-utils/ghe-rsync-size"
170170

171+
#Check if GHE_DATA_DIR is NFS mounted
172+
fs_info=$(stat -f -c "%T" "$GHE_DATA_DIR") || true
173+
if [ "$fs_info" == "nfs" ]; then
174+
echo "Warning: NFS (Network File System) detected for $GHE_DATA_DIR" 1>&2
175+
echo "Please review https://gh.io/backup-utils-storage-requirements for details." 1>&2
176+
fi
177+
171178
#Display dir requirements for repositories and mysql
172179
echo "" 1>&2
173180
echo "Checking host for sufficient space for a backup..." 1>&2

bin/ghe-restore

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,8 @@ cleanup () {
138138
if ! rm -f "${GHE_DATA_DIR}/in-progress-restore"; then
139139
log_error "Failed to remove in-progress file" 1>&3
140140
fi
141+
142+
bm_end "$(basename $0)"
141143
}
142144

143145
# This function's type definition is being passed to a remote host via `ghe-ssh` but is not used locally.
@@ -315,13 +317,14 @@ fi
315317
export PROGRESS_TOTAL=$((OPTIONAL_STEPS + 7))
316318

317319
init-progress
318-
echo "$PROGRESS_TOTAL" > /tmp/backup-utils-progress-total
320+
echo "$PROGRESS_TOTAL" > /tmp/backup-utils-progress/total
319321
export PROGRESS_TYPE="Restore"
320-
echo "$PROGRESS_TYPE" > /tmp/backup-utils-progress-type
322+
echo "$PROGRESS_TYPE" > /tmp/backup-utils-progress/type
321323
export PROGRESS=0 # Used to track progress of restore
322-
echo "$PROGRESS" > /tmp/backup-utils-progress
324+
echo "$PROGRESS" > /tmp/backup-utils-progress/progress
323325

324326
# Log restore start message locally and in /var/log/syslog on remote instance
327+
bm_start "$(basename $0)"
325328
START_TIME=$(date +%s)
326329
log_info "Starting restore of $GHE_HOSTNAME with backup-utils v$BACKUP_UTILS_VERSION from snapshot $GHE_RESTORE_SNAPSHOT"
327330

docs/requirements.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ Using a [case sensitive][7] file system is also required to avoid conflicts.
5757

5858
Performance of backup and restore operations are also dependent on the backup host's storage. We recommend using a high performance storage system with low latency and high IOPS.
5959

60+
Please avoid using an NFS mount for the data directory (where backup data is stored) as this can cause performance issues and timeouts during backups.
61+
6062
## GitHub Enterprise Server version requirements
6163

6264
Starting with Backup Utilities v2.13.0, version support is inline with that of the

script/cibuild

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ set -e
55
# Enable verbose logging of ssh commands
66
export GHE_VERBOSE_SSH=true
77

8-
if ! find test -name "test-*.sh" -print0 | xargs -0 -P 4 -n 1 /bin/bash; then
8+
if ! find test -name "test-*.sh" -print0 | xargs -0 -n 1 /bin/bash; then
99
exit 1
1010
fi
1111

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -652,12 +652,21 @@ restore-secret() {
652652

653653
#initialize progress tracking by clearing out the temp files used to track
654654
init-progress() {
655-
rm -f /tmp/backup-utils-progress*
655+
if [ -d /tmp/backup-utils-progress ]; then
656+
rm -rf /tmp/backup-utils-progress/*
657+
else
658+
mkdir /tmp/backup-utils-progress
659+
fi
660+
touch /tmp/backup-utils-progress/total
661+
touch /tmp/backup-utils-progress/type
662+
touch /tmp/backup-utils-progress/progress
663+
touch /tmp/backup-utils-progress/info
664+
chmod -R 777 /tmp/backup-utils-progress
656665
}
657666

658667

659668
#increase total count of progress
660669
increment-progress-total-count() {
661670
((PROGRESS_TOTAL += $1))
662-
echo "$PROGRESS_TOTAL" > /tmp/backup-utils-progress-total
671+
echo "$PROGRESS_TOTAL" > /tmp/backup-utils-progress/total
663672
}

0 commit comments

Comments
 (0)