Skip to content

Commit 9d47541

Browse files
authored
Merge pull request #1091 from github/3.10.0-release
3.10.0 RC release
2 parents e939e6b + 35b9046 commit 9d47541

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+1666
-152
lines changed

.github/workflows/lint.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
name: Lint Code Base
22

33
on:
4-
push:
5-
branches-ignore: [master]
64
pull_request:
75
branches: [master]
86

.github/workflows/main.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ name: Test and build
22

33
on: [pull_request]
44

5-
65
jobs:
76
build:
87
strategy:

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@
22
/data
33
/dist
44
.DS_Store
5+
dash
6+
parallel

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/*

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
SHELL = /bin/sh
22

33
test: info
4+
@echo Running tests
45
@script/cibuild --no-package
56

67
info:

backup.config-example

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

19+
# Pruning snapshots can be scheduled outside of the backup process.
20+
# If set to 'yes', snapshots will not be pruned by ghe-backup.
21+
# Instead, ghe-pruning-snapshots will need to be invoked separately via cron
22+
#GHE_PRUNING_SCHEDULED=yes
23+
24+
# If --incremental is used to generate incremental MySQL backups with ghe-backup,
25+
# then you need to specify how many cycles of full and incremental backups will be
26+
# performed before the next full backup is created.
27+
# For example, if `GHE_INCREMENTAL_BACKUP_MAX` is set to 14, backup-utils will
28+
# run 1 full backup and then 13 incremental backups before performing another full backup on the next cycle.
29+
#GHE_INCREMENTAL_BACKUP_MAX=14
30+
31+
# If GHE_SKIP_CHECKS is set to true (or if --skip-checks is used with ghe-backup) then ghe-host-check
32+
# disk space validation and software version checks on the backup-host will be disabled.
33+
#GHE_SKIP_CHECKS=false
34+
1935
# The hostname of the GitHub appliance to restore. If you've set up a separate
2036
# GitHub appliance to act as a standby for recovery, specify its IP or hostname
2137
# here. The host to restore to may also be specified directly when running

bin/ghe-backup

Lines changed: 84 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@
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+
#/ -i | --incremental Incremental backup
12+
#/ --skip-checks Skip storage/sw version checks
1113
#/
1214

1315
set -e
@@ -27,6 +29,14 @@ while true; do
2729
export GHE_VERBOSE=true
2830
shift
2931
;;
32+
-i|--incremental)
33+
export GHE_INCREMENTAL=true
34+
shift
35+
;;
36+
--skip-checks)
37+
export GHE_SKIP_CHECKS=true
38+
shift
39+
;;
3040
-*)
3141
echo "Error: invalid argument: '$1'" 1>&2
3242
exit 1
@@ -37,11 +47,45 @@ while true; do
3747
esac
3848
done
3949

50+
4051
export CALLING_SCRIPT="ghe-backup"
52+
4153
# Bring in the backup configuration
4254
# shellcheck source=share/github-backup-utils/ghe-backup-config
4355
. "$( dirname "${BASH_SOURCE[0]}" )/../share/github-backup-utils/ghe-backup-config"
4456

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
81+
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
4589
# Check to make sure moreutils parallel is installed and working properly
4690
ghe_parallel_check
4791

@@ -121,7 +165,7 @@ ghe_restore_check
121165
# Check to see if there is a running backup
122166
if [ -h ../in-progress ]; then
123167

124-
log_error "Error: detected a backup already in progress from a previous version of ghe-backup. \nIf there is no backup in progress anymore, please remove \nthe $GHE_DATA_DIR/in-progress file." 1>&2
168+
log_error "Detected a backup already in progress from a previous version of ghe-backup. \nIf there is no backup in progress anymore, please remove \nthe $GHE_DATA_DIR/in-progress file." >&2
125169
exit 1
126170
fi
127171

@@ -139,17 +183,39 @@ if [ -f ../in-progress ]; then
139183
fi
140184
fi
141185

186+
# Perform a host connection check and establish the remote appliance version.
187+
# The version is available in the GHE_REMOTE_VERSION variable and also written
188+
# to a version file in the snapshot directory itself.
189+
ghe_remote_version_required
190+
echo "$GHE_REMOTE_VERSION" > version
191+
192+
# check that incremental settings are valid if set
193+
is_inc=$(is_incremental_backup_feature_on)
194+
195+
if [ "$is_inc" = true ]; then
196+
if [ "$GHE_VERSION_MAJOR" -lt 3 ]; then
197+
log_error "Can only perform incremental backups on enterprise version 3.10 or higher"
198+
exit 1
199+
fi
200+
if [ "$GHE_VERSION_MINOR" -lt 10 ]; then
201+
log_error "Can only perform incremental backups on enterprise version 3.10 or higher"
202+
exit 1
203+
fi
204+
205+
incremental_backup_check
206+
# If everything is ok, check if we have hit GHE_MAX_INCREMENTAL_BACKUPS, performing pruning actions if necessary
207+
check_for_incremental_max_backups
208+
# initialize incremental backup if it hasn't been done yet
209+
incremental_backup_init
210+
fi
211+
142212
echo "$GHE_SNAPSHOT_TIMESTAMP $$" > ../in-progress
143213
echo "$GHE_SNAPSHOT_TIMESTAMP $$" > "${GHE_DATA_DIR}/in-progress-backup"
144214

145215
START_TIME=$(date +%s)
146216
log_info "Starting backup of $GHE_HOSTNAME with backup-utils v$BACKUP_UTILS_VERSION in snapshot $GHE_SNAPSHOT_TIMESTAMP"
147217

148-
# Perform a host connection check and establish the remote appliance version.
149-
# The version is available in the GHE_REMOTE_VERSION variable and also written
150-
# to a version file in the snapshot directory itself.
151-
ghe_remote_version_required
152-
echo "$GHE_REMOTE_VERSION" > version
218+
153219

154220
if [ -n "$GHE_ALLOW_REPLICA_BACKUP" ]; then
155221
echo "Warning: backing up a high availability replica may result in inconsistent or unreliable backups."
@@ -259,6 +325,7 @@ echo \"$cmd_title\"
259325
ghe-backup-git-hooks || printf %s \"git-hooks \" >> \"$failures_file\"")
260326

261327
if [ "$GHE_BACKUP_STRATEGY" = "rsync" ]; then
328+
increment-progress-total-count 1
262329
cmd_title=$(log_info "Backing up Elasticsearch indices ...")
263330
commands+=("
264331
echo \"$cmd_title\"
@@ -292,7 +359,13 @@ if [ -z "$failures" ]; then
292359
rm -f "../current"
293360
ln -s "$GHE_SNAPSHOT_TIMESTAMP" "../current"
294361

295-
ghe-prune-snapshots
362+
if [[ $GHE_PRUNING_SCHEDULED != "yes" ]]; then
363+
ghe-prune-snapshots
364+
else
365+
log_info "Expired and incomplete snapshots to be pruned separately"
366+
fi
367+
else
368+
log_info "Skipping pruning snapshots, since some backups failed..."
296369
fi
297370

298371
END_TIME=$(date +%s)
@@ -306,6 +379,7 @@ else
306379
steps="${failures// /, }"
307380
ghe_remote_logger "Completed backup from $(hostname) / snapshot $GHE_SNAPSHOT_TIMESTAMP with failures: ${steps}."
308381
log_error "Error: Snapshot incomplete. Some steps failed: ${steps}. "
382+
ghe_backup_finished
309383
exit 1
310384
fi
311385

bin/ghe-backup-progress

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#!/usr/bin/env bash
2+
#/ Usage: ghe-backup-progress [--once]
3+
#/ Tracks the completed steps of a backup or restore operation.
4+
#/
5+
#/ By default the progress is printed every continuously or until a key is pressed.
6+
#/ Use the --once option to print the current progress once and exit.
7+
#/
8+
#/ Options:
9+
#/ --once Don't loop, just print the current progress once.
10+
#
11+
set -e
12+
13+
while true; do
14+
case "$1" in
15+
-o|--once)
16+
ONCE=1
17+
shift
18+
;;
19+
-h|--help)
20+
export GHE_SHOW_HELP=true
21+
shift
22+
;;
23+
-*)
24+
echo "Unknown option: $1" >&2
25+
exit 1
26+
;;
27+
*)
28+
break
29+
;;
30+
esac
31+
done
32+
33+
check_for_progress_file() {
34+
if [ ! -f /tmp/backup-utils-progress-info ]; then
35+
echo "No progress file found. Has a backup or restore been started?"
36+
exit 1
37+
fi
38+
}
39+
40+
if [ -n "$ONCE" ]; then
41+
check_for_progress_file
42+
cat /tmp/backup-utils-progress-info
43+
else
44+
check_for_progress_file
45+
clear
46+
cat /tmp/backup-utils-progress-info
47+
while true; do
48+
if read -r -t 1 -n 1; then
49+
clear
50+
exit ;
51+
else
52+
clear
53+
cat /tmp/backup-utils-progress-info
54+
fi
55+
done
56+
fi

0 commit comments

Comments
 (0)