Skip to content

Commit 27b74c8

Browse files
authored
Merge pull request #266 from github/snh/stop-jobs-during-restore
Stop cron and timerd during restore
2 parents a30ed3d + b006281 commit 27b74c8

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

bin/ghe-restore

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,17 @@ fi
200200
ghe-backup-store-version ||
201201
echo "Warning: storing backup-utils version remotely failed."
202202

203+
# Stop cron and timerd, as scheduled jobs may disrupt the restore process.
204+
if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then
205+
if $cluster; then
206+
ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo service cron stop"
207+
ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo service github-timerd stop"
208+
else
209+
ghe-ssh "$GHE_HOSTNAME" -- "sudo service cron stop"
210+
ghe-ssh "$GHE_HOSTNAME" -- "sudo service github-timerd stop"
211+
fi
212+
fi
213+
203214
# Restore settings and license if restoring to an unconfigured appliance or when
204215
# specified manually.
205216
if $restore_settings; then
@@ -323,6 +334,15 @@ elif $instance_configured; then
323334
fi
324335
fi
325336

337+
# Start cron. Timerd will start automatically as part of the config run.
338+
if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then
339+
if $cluster; then
340+
ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo service cron start"
341+
else
342+
ghe-ssh "$GHE_HOSTNAME" -- "sudo service cron start"
343+
fi
344+
fi
345+
326346
# Update the remote status to "complete". This has to happen before importing
327347
# ssh host keys because subsequent commands will fail due to the host key
328348
# changing otherwise.

test/bin/service

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env bash
2+
# Fake service command for tests.
3+
true

0 commit comments

Comments
 (0)