Skip to content

Commit 7bc6c13

Browse files
authored
Merge pull request #661 from github/hao/backup-utils-github-env
Revert backup-utils gitHub env and a few more fixes
2 parents 3c11938 + 696749e commit 7bc6c13

File tree

10 files changed

+25
-34
lines changed

10 files changed

+25
-34
lines changed

bin/ghe-backup

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -137,16 +137,6 @@ if [ -f ../in-progress ]; then
137137
fi
138138
fi
139139

140-
# Figure out which github-env we should use during backup
141-
GITHUB_ENV_SHELL=
142-
if ghe-ssh "$GHE_HOSTNAME" -- \
143-
'[ -x "$(command -v github-env-dispatch)" ]'; then
144-
GITHUB_ENV_SHELL=github-env-dispatch
145-
else
146-
GITHUB_ENV_SHELL=github-env
147-
fi
148-
export GITHUB_ENV_SHELL
149-
150140
echo "$GHE_SNAPSHOT_TIMESTAMP $$" > ../in-progress
151141

152142
echo "Starting backup of $GHE_HOSTNAME with backup-utils v$BACKUP_UTILS_VERSION in snapshot $GHE_SNAPSHOT_TIMESTAMP"

bin/ghe-restore

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -144,16 +144,6 @@ if ghe-ssh "$GHE_HOSTNAME" -- \
144144
fi
145145
export CLUSTER
146146

147-
# Figure out which github-env we should use during restore
148-
GITHUB_ENV_SHELL=
149-
if ghe-ssh "$GHE_HOSTNAME" -- \
150-
'[ -x "$(command -v github-env-dispatch)" ]'; then
151-
GITHUB_ENV_SHELL=github-env-dispatch
152-
else
153-
GITHUB_ENV_SHELL=github-env
154-
fi
155-
export GITHUB_ENV_SHELL
156-
157147
# Restoring a cluster backup to a standalone appliance is not supported
158148
if ! $CLUSTER && [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then
159149
echo "Error: Snapshot from a GitHub Enterprise cluster cannot be restored" \
@@ -260,8 +250,10 @@ if $CLUSTER; then
260250
fi
261251

262252
if [ "$GHE_VERSION_MAJOR" -eq "3" ]; then
263-
if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo nomad stop github-timerd"; then
264-
ghe_verbose "* Warning: Failed to stop github-timerd on one or more nodes"
253+
if ghe-ssh "$GHE_HOSTNAME" -- "systemctl -q is-active nomad && nomad job status --short github-timerd &>/dev/null"; then
254+
if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo nomad stop github-timerd 1>/dev/null"; then
255+
ghe_verbose "* Warning: Failed to stop github-timerd on one or more nodes"
256+
fi
265257
fi
266258
else
267259
if ! ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo service github-timerd stop"; then
@@ -274,8 +266,10 @@ else
274266
fi
275267

276268
if [ "$GHE_VERSION_MAJOR" -eq "3" ]; then
277-
if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo nomad stop github-timerd"; then
278-
ghe_verbose "* Warning: Failed to stop github-timerd"
269+
if ghe-ssh "$GHE_HOSTNAME" -- "systemctl -q is-active nomad && nomad job status --short github-timerd &>/dev/null"; then
270+
if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo nomad stop github-timerd 1>/dev/null"; then
271+
ghe_verbose "* Warning: Failed to stop github-timerd"
272+
fi
279273
fi
280274
else
281275
if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo service github-timerd stop"; then
@@ -414,9 +408,11 @@ echo "sudo restart -q memcached 2>/dev/null || true" |
414408
# config run to perform data migrations.
415409
if $CLUSTER; then
416410
echo "Configuring cluster ..."
411+
ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- ghe-nomad-cleanup"
417412
ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-config-apply" 1>&3 2>&3
418413
elif $instance_configured; then
419414
echo "Configuring appliance ..."
415+
ghe-ssh "$GHE_HOSTNAME" -- "ghe-nomad-cleanup"
420416
ghe-ssh "$GHE_HOSTNAME" -- "ghe-config-apply" 1>&3 2>&3
421417
fi
422418

share/github-backup-utils/ghe-backup-repositories

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ fi
123123
# more performant than performing over an SSH pipe.
124124
#
125125
bm_start "$(basename $0) - Generating routes"
126-
echo "$GITHUB_ENV_SHELL ./bin/dgit-cluster-backup-routes > $remote_routes_list" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash
126+
echo "github-env ./bin/dgit-cluster-backup-routes > $remote_routes_list" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash
127127
ghe-ssh "$GHE_HOSTNAME" -- cat $remote_routes_list | ghe_debug
128128
bm_end "$(basename $0) - Generating routes"
129129

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ fi
9191
# more performant than performing over an SSH pipe.
9292
#
9393
bm_start "$(basename $0) - Generating routes"
94-
echo "$GITHUB_ENV_SHELL ./bin/storage-cluster-backup-routes > $remote_routes_list" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash
94+
echo "github-env ./bin/storage-cluster-backup-routes > $remote_routes_list" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash
9595
ghe-ssh "$GHE_HOSTNAME" -- cat $remote_routes_list | ghe_debug
9696
bm_end "$(basename $0) - Generating routes"
9797

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ cat $tmp_list | ghe_debug
108108
bm_end "$(basename $0) - Transferring pages list"
109109

110110
bm_start "$(basename $0) - Generating routes"
111-
echo "cat $remote_tmp_list | $GITHUB_ENV_SHELL ./bin/dpages-cluster-restore-routes > $remote_routes_list" | ghe-ssh "$GHE_HOSTNAME" /bin/bash
111+
echo "cat $remote_tmp_list | github-env ./bin/dpages-cluster-restore-routes > $remote_routes_list" | ghe-ssh "$GHE_HOSTNAME" /bin/bash
112112
ghe-ssh "$GHE_HOSTNAME" -- cat $remote_routes_list | ghe_debug
113113
bm_end "$(basename $0) - Generating routes"
114114

@@ -150,7 +150,7 @@ if $CLUSTER; then
150150
ghe-ssh "$GHE_HOSTNAME" -- /bin/bash >&3 <<EOF
151151
split -l 1000 $remote_routes_list $remote_tempdir/chunk
152152
chunks=\$(find $remote_tempdir/ -name chunk\*)
153-
parallel -i /bin/sh -c "cat {} | $GITHUB_ENV_SHELL ./bin/dpages-cluster-restore-finalize" -- \$chunks
153+
parallel -i /bin/sh -c "cat {} | github-env ./bin/dpages-cluster-restore-finalize" -- \$chunks
154154
EOF
155155
bm_end "$(basename $0) - Finalizing routes"
156156
fi

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ cat $tmp_list | ghe_debug
120120
bm_end "$(basename $0) - Transferring network list"
121121

122122
bm_start "$(basename $0) - Generating routes"
123-
echo "cat $remote_tmp_list | $GITHUB_ENV_SHELL ./bin/dgit-cluster-restore-routes > $remote_routes_list" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash
123+
echo "cat $remote_tmp_list | github-env ./bin/dgit-cluster-restore-routes > $remote_routes_list" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash
124124
ghe-ssh "$GHE_HOSTNAME" -- cat $remote_routes_list | ghe_debug
125125
bm_end "$(basename $0) - Generating routes"
126126

@@ -183,7 +183,7 @@ if $CLUSTER; then
183183
ghe-ssh "$GHE_HOSTNAME" -- /bin/bash >&3 <<EOF
184184
split -l 1000 $remote_to_restore $remote_tempdir/chunk
185185
chunks=\$(find $remote_tempdir/ -name chunk\*)
186-
parallel -i /bin/sh -c "cat {} | $GITHUB_ENV_SHELL ./bin/dgit-cluster-restore-finalize 2>>$remote_warnings" -- \$chunks
186+
parallel -i /bin/sh -c "cat {} | github-env ./bin/dgit-cluster-restore-finalize 2>>$remote_warnings" -- \$chunks
187187
EOF
188188
bm_end "$(basename $0) - Finalizing routes"
189189
fi

share/github-backup-utils/ghe-restore-repositories-gist

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ cat $tmp_list | ghe_debug
110110
bm_end "$(basename $0) - Transferring gist list"
111111

112112
bm_start "$(basename $0) - Generating routes"
113-
echo "cat $remote_tmp_list | $GITHUB_ENV_SHELL ./bin/gist-cluster-restore-routes > $remote_routes_list" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash
113+
echo "cat $remote_tmp_list | github-env ./bin/gist-cluster-restore-routes > $remote_routes_list" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash
114114
ghe-ssh "$GHE_HOSTNAME" -- cat $remote_routes_list | ghe_debug
115115
bm_end "$(basename $0) - Generating routes"
116116

@@ -155,7 +155,7 @@ if $CLUSTER; then
155155
ghe-ssh "$GHE_HOSTNAME" -- /bin/bash >&3 <<EOF
156156
split -l 1000 $remote_to_restore $remote_tempdir/chunk
157157
chunks=\$(find $remote_tempdir/ -name chunk\*)
158-
parallel -i /bin/sh -c "cat {} | $GITHUB_ENV_SHELL ./bin/gist-cluster-restore-finalize 2>>$remote_warnings" -- \$chunks
158+
parallel -i /bin/sh -c "cat {} | github-env ./bin/gist-cluster-restore-finalize 2>>$remote_warnings" -- \$chunks
159159
EOF
160160
bm_end "$(basename $0) - Finalizing routes"
161161
fi

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ cat $tmp_list | ghe_debug
103103
bm_end "$(basename $0) - Transferring object list"
104104

105105
bm_start "$(basename $0) - Generating routes"
106-
echo "cat $remote_tmp_list | $GITHUB_ENV_SHELL ./bin/storage-cluster-restore-routes > $remote_routes_list" | ghe-ssh "$GHE_HOSTNAME" /bin/bash
106+
echo "cat $remote_tmp_list | github-env ./bin/storage-cluster-restore-routes > $remote_routes_list" | ghe-ssh "$GHE_HOSTNAME" /bin/bash
107107
ghe-ssh "$GHE_HOSTNAME" -- cat $remote_routes_list | ghe_debug
108108
bm_end "$(basename $0) - Generating routes"
109109

@@ -165,7 +165,7 @@ if $CLUSTER; then
165165
ghe-ssh "$GHE_HOSTNAME" -- /bin/bash >&3 <<EOF
166166
split -l 1000 $remote_routes_list $remote_tempdir/chunk
167167
chunks=\$(find $remote_tempdir/ -name chunk\*)
168-
parallel -i /bin/sh -c "cat {} | $GITHUB_ENV_SHELL ./bin/storage-cluster-restore-finalize" -- \$chunks
168+
parallel -i /bin/sh -c "cat {} | github-env ./bin/storage-cluster-restore-finalize" -- \$chunks
169169
EOF
170170
bm_end "$(basename $0) - Finalizing routes"
171171
fi

test/bin/ghe-nomad-cleanup

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env bash
2+
# Usage: ghe-nomad-cleanup
3+
# Emulates the remote GitHub ghe-nomad-cleanup command. Tests use this
4+
# to assert that the command was executed.
5+
echo "$(basename $0)" "'$(cat)'" "OK"
File renamed without changes.

0 commit comments

Comments
 (0)