Skip to content

Commit cfb215a

Browse files
committed
Merge branch 'master' into use-ghe-redis-cli
2 parents d79f238 + cd619ae commit cfb215a

File tree

6 files changed

+90
-25
lines changed

6 files changed

+90
-25
lines changed

Dockerfile.alpine

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
FROM alpine:latest
2+
3+
RUN apk --update --no-cache add \
4+
tar \
5+
rsync \
6+
ca-certificates \
7+
openssh \
8+
git \
9+
bash \
10+
gawk \
11+
procps
12+
13+
WORKDIR /backup-utils
14+
ADD https://github.com/github/backup-utils/archive/stable.tar.gz /
15+
RUN tar xzvf /stable.tar.gz --strip-components=1 -C /backup-utils && \
16+
mv /usr/bin/gawk /usr/bin/awk && \
17+
rm -r /stable.tar.gz
18+
19+
RUN chmod +x /backup-utils/share/github-backup-utils/ghe-docker-init
20+
21+
ENTRYPOINT ["/backup-utils/share/github-backup-utils/ghe-docker-init"]
22+
CMD ["ghe-host-check"]

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

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,20 @@ ghe_parallel_check() {
7272
fi
7373

7474
# Some machines may have both moreutils parallel and GNU parallel installed.
75+
# Check some variants to find it
7576
GHE_PARALLEL_COMMAND="parallel"
76-
if [ -x "/usr/bin/parallel.moreutils" ]; then
77-
GHE_PARALLEL_COMMAND="/usr/bin/parallel.moreutils"
78-
fi
77+
local x
78+
for x in \
79+
/usr/bin/parallel.moreutils \
80+
/usr/bin/parallel_moreutils \
81+
/usr/bin/moreutils.parallel \
82+
/usr/bin/moreutils_parallel \
83+
; do
84+
if [ -x "${x}" ]; then
85+
GHE_PARALLEL_COMMAND="${x}"
86+
break
87+
fi
88+
done
7989

8090
# Check that the GHE_PARALLEL_COMMAND is pointing to moreutils parallel
8191
if ! $GHE_PARALLEL_COMMAND -h | grep -q "parallel \[OPTIONS\] command -- arguments"; then

share/github-backup-utils/ghe-restore-storage

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ set -e
1111
# shellcheck source=share/github-backup-utils/ghe-backup-config
1212
. "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config"
1313

14+
# Check to make sure moreutils parallel is installed and working properly
15+
ghe_parallel_check
16+
1417
# Show usage and bail with no arguments
1518
[ -z "$*" ] && print_usage
1619

@@ -128,17 +131,32 @@ for file_list in $tempdir/*.rsync; do
128131
else
129132
server=$host
130133
fi
134+
131135
storage_user=$(ghe-ssh $ssh_config_file_opt $server:$port -- stat -c %U /data/user/storage || echo git)
132136

133-
ghe_verbose "* Transferring data to $server ..."
137+
rsync_commands+=("
138+
if [ -n \"$GHE_VERBOSE\" ]; then
139+
echo \"* Transferring data to $server ...\" 1>&3
140+
fi
141+
134142
ghe-rsync -arvHR --delete \
135-
-e "ssh -q $opts -p $port $ssh_config_file_opt -l $user" \
136-
--rsync-path="sudo -u $storage_user rsync" \
143+
-e \"ssh -q $opts -p $port $ssh_config_file_opt -l $user\" \
144+
--rsync-path=\"sudo -u $storage_user rsync\" \
137145
--files-from=$file_list \
138146
--size-only \
139-
"$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/storage/./" \
140-
"$server:$GHE_REMOTE_DATA_USER_DIR/storage/" 1>&3
147+
\"$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/storage/./\" \
148+
\"$server:$GHE_REMOTE_DATA_USER_DIR/storage/\" 1>&3
149+
")
141150
done
151+
152+
if [ "$GHE_PARALLEL_ENABLED" = "yes" ]; then
153+
$GHE_PARALLEL_COMMAND $GHE_PARALLEL_RSYNC_COMMAND_OPTIONS -- "${rsync_commands[@]}"
154+
else
155+
for c in "${rsync_commands[@]}"; do
156+
eval "$c"
157+
done
158+
fi
159+
142160
bm_end "$(basename $0) - Restoring objects"
143161

144162
if $CLUSTER; then

test/bin/python

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,12 @@ cat >/dev/null
1717

1818
# verify the python compiles at least. if this fails then the python code passed
1919
# to -c failed basic syntax checks.
20+
# Compiler package ws removed in Py3
21+
# see https://www.python.org/dev/peps/pep-3108/#id53
22+
# The closest replacement is the ast package
23+
# https://docs.python.org/3/library/ast.html
2024
echo "$2" |
21-
/usr/bin/python2.7 -c "import sys; __import__('compiler').parse(sys.stdin.read())"
25+
/usr/bin/python3 -c "import sys; __import__('ast').parse(sys.stdin.read())"
2226

2327
# pretend we found zero processes.
2428
echo 0

test/test-ghe-restore.sh

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,7 @@ begin_test "ghe-restore cluster"
539539
(
540540
set -e
541541
rm -rf "$GHE_REMOTE_ROOT_DIR"
542+
setup_moreutils_parallel
542543
setup_remote_metadata
543544
setup_remote_cluster
544545
echo "cluster" > "$GHE_DATA_DIR/current/strategy"
@@ -550,21 +551,14 @@ begin_test "ghe-restore cluster"
550551
GHE_RESTORE_HOST=127.0.0.1
551552
export GHE_RESTORE_HOST
552553

553-
# CI servers may have moreutils parallel and GNU parallel installed. We need moreutils parallel.
554-
if [ -x "/usr/bin/parallel.moreutils" ]; then
555-
ln -sf /usr/bin/parallel.moreutils "$ROOTDIR/test/bin/parallel"
556-
fi
557-
558554
# run ghe-restore and write output to file for asserting against
559555
if ! ghe-restore -v -f > "$TRASHDIR/restore-out" 2>&1; then
560556
cat "$TRASHDIR/restore-out"
561557
: ghe-restore should have exited successfully
562558
false
563559
fi
564560

565-
if [ -h "$ROOTDIR/test/bin/parallel" ]; then
566-
unlink "$ROOTDIR/test/bin/parallel"
567-
fi
561+
cleanup_moreutils_parallel
568562

569563
# for debugging
570564
cat "$TRASHDIR/restore-out"
@@ -609,6 +603,7 @@ begin_test "ghe-restore missing directories or files from source snapshot displa
609603
# Tests the scenario where something exists in the database, but not on disk.
610604
set -e
611605
rm -rf "$GHE_REMOTE_ROOT_DIR"
606+
setup_moreutils_parallel
612607
setup_remote_metadata
613608
setup_remote_cluster
614609
echo "cluster" > "$GHE_DATA_DIR/current/strategy"
@@ -620,11 +615,6 @@ begin_test "ghe-restore missing directories or files from source snapshot displa
620615
GHE_RESTORE_HOST=127.0.0.1
621616
export GHE_RESTORE_HOST
622617

623-
# CI servers may have moreutils parallel and GNU parallel installed. We need moreutils parallel.
624-
if [ -x "/usr/bin/parallel.moreutils" ]; then
625-
ln -sf /usr/bin/parallel.moreutils "$ROOTDIR/test/bin/parallel"
626-
fi
627-
628618
# Tell dgit-cluster-restore-finalize and gist-cluster-restore-finalize to return warnings
629619
export GHE_DGIT_CLUSTER_RESTORE_FINALIZE_WARNING=1
630620
export GHE_GIST_CLUSTER_RESTORE_FINALIZE_WARNING=1
@@ -636,9 +626,7 @@ begin_test "ghe-restore missing directories or files from source snapshot displa
636626
false
637627
fi
638628

639-
if [ -h "$ROOTDIR/test/bin/parallel" ]; then
640-
unlink "$ROOTDIR/test/bin/parallel"
641-
fi
629+
cleanup_moreutils_parallel
642630

643631
# for debugging
644632
cat "$TRASHDIR/restore-out"

test/testlib.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,3 +519,26 @@ enable_actions() {
519519
is_actions_enabled() {
520520
ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.actions.enabled'
521521
}
522+
523+
setup_moreutils_parallel() {
524+
# CI servers may have moreutils parallel and GNU parallel installed.
525+
# We need moreutils parallel
526+
local x
527+
for x in \
528+
/usr/bin/parallel.moreutils \
529+
/usr/bin/parallel_moreutils \
530+
/usr/bin/moreutils.parallel \
531+
/usr/bin/moreutils_parallel \
532+
; do
533+
if [ -x "${x}" ]; then
534+
ln -sf "${x}" "$ROOTDIR/test/bin/parallel"
535+
break
536+
fi
537+
done
538+
}
539+
540+
cleanup_moreutils_parallel() {
541+
if [ -h "$ROOTDIR/test/bin/parallel" ]; then
542+
unlink "$ROOTDIR/test/bin/parallel"
543+
fi
544+
}

0 commit comments

Comments
 (0)