Skip to content

Commit 5415ac1

Browse files
authored
Merge branch 'master' into master
2 parents ee5afbb + bbfc42f commit 5415ac1

File tree

11 files changed

+52
-13
lines changed

11 files changed

+52
-13
lines changed

bin/ghe-host-check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ fi
131131

132132
# backup-utils 2.13 onwards limits support to the current and previous two releases
133133
# of GitHub Enterprise Server.
134-
supported_minimum_version="3.1.0"
134+
supported_minimum_version="3.2.0"
135135

136136
if [ "$(version $version)" -ge "$(version $supported_minimum_version)" ]; then
137137
supported=1

bin/ghe-restore

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -261,12 +261,22 @@ if $instance_configured; then
261261
fi
262262
fi
263263

264+
# Get GHES release version in major.minor format
265+
RELEASE_VERSION=$(ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --get core.package-version' | cut -d '.' -f 1,2)
266+
264267
# Make sure the GitHub appliance has Actions enabled if the snapshot contains Actions data.
268+
# If above is true, also check if ac is present in appliance then snapshot should also contains ac databases
265269
if [ -d "$GHE_RESTORE_SNAPSHOT_PATH/mssql" ] || [ -d "$GHE_RESTORE_SNAPSHOT_PATH/actions" ]; then
266-
if ! ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.actions.enabled'; then
267-
# Get GHES release version in major.minor format
268-
RELEASE_VERSION=$(ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --get core.package-version' | cut -d '.' -f 1,2)
269-
270+
if ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.actions.enabled'; then
271+
ac_db_ghe=$(echo 'ghe-mssql-console -y -n -q "SELECT name FROM sys.databases" | grep -i "ArtifactCache" | wc -l | tr -d " "' | ghe-ssh "$GHE_HOSTNAME" /bin/bash)
272+
ac_db_snapshot=$(find "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/mssql/" -maxdepth 1 -name 'ArtifactCache*.bak' | wc -l | tr -d " ")
273+
if [[ $ac_db_ghe -gt 0 && $ac_db_snapshot -eq 0 ]]; then
274+
echo "Error: $GHE_HOSTNAME contains ArtifactCache databases but no ArtifactCache databases are present in snapshot. Aborting" 1>&2
275+
echo "Please delete ArtifactCache databases from $GHE_HOSTNAME and retry" 1>&2
276+
echo "Steps to delete ArtifactCache databases can be found here: https://docs.github.com/en/enterprise-server@$RELEASE_VERSION/admin/github-actions/advanced-configuration-and-troubleshooting/deleting-artifact-cache-databases" 1>&2
277+
exit 1
278+
fi
279+
else
270280
echo "Error: $GHE_HOSTNAME must have GitHub Actions enabled before restoring since the snapshot contains Actions data. Aborting." 1>&2
271281
echo "Setup details for enabling Actions can be found here: https://docs.github.com/en/enterprise-server@$RELEASE_VERSION/admin/github-actions/advanced-configuration-and-troubleshooting/backing-up-and-restoring-github-enterprise-server-with-github-actions-enabled" 1>&2
272282
exit 1
@@ -446,6 +456,14 @@ echo "Restarting memcached ..." 1>&3
446456
echo "sudo restart -q memcached 2>/dev/null || true" |
447457
ghe-ssh "$GHE_HOSTNAME" -- /bin/sh
448458

459+
# Prevent GitHub Connect jobs running before we've had a chance to reset
460+
# the configuration by setting the last run date to now.
461+
if ! $RESTORE_SETTINGS; then
462+
echo "Setting last run date for GitHub Connect jobs ..." 1>&3
463+
echo "now=$(date +%s.0000000); ghe-redis-cli mset timer:UpdateConnectInstallationInfo \$now timer:UploadEnterpriseServerUserAccountsJob \$now timer:UploadConnectMetricsJob \$now timer:GitHubConnectPushNewContributionsJob \$now" |
464+
ghe-ssh "$GHE_HOSTNAME" -- /bin/sh 1>&3
465+
fi
466+
449467
# When restoring to a host that has already been configured, kick off a
450468
# config run to perform data migrations.
451469
if $CLUSTER; then

debian/changelog

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
github-backup-utils (3.4.0) UNRELEASED; urgency=medium
2+
3+
* Add anchor to usage doc for settings restore #865
4+
5+
-- Steve Culver <[email protected]> Tue, 15 Feb 2022 19:25:09 +0000
6+
17
github-backup-utils (3.3.1) UNRELEASED; urgency=medium
28

39
* Fix compat issue with ghe-actions-start during maintenance mode #836

script/package-deb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@ git checkout -q "$PKG_HEAD"
2626

2727
debuild -uc -us 1>&2
2828
cd ..
29-
files=$(ls -1 *.deb *.tar.gz *.dsc *.changes)
29+
files=$(ls -1 *.deb *.tar.xz *.dsc *.changes)
3030
mv $files ../
3131
for f in $files; do echo "dist/$f"; done

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,15 @@ cleanup() {
9090

9191
# Enable remote GC operations
9292
for hostname in $hostnames; do
93-
ghe-gc-enable $ssh_config_file_opt $hostname:$port || true
93+
ghe-gc-enable $ssh_config_file_opt $hostname:$port || {
94+
echo "Re-enable gc on $hostname failed, please manually delete $SYNC_IN_PROGRESS_FILE" 1>&2
95+
}
9496
done
9597

9698
ghe-ssh "$GHE_HOSTNAME" -- rm -rf $remote_tempdir
9799
rm -rf $tempdir
98100
}
99-
trap 'cleanup' EXIT
100-
trap 'exit $?' INT # ^C always terminate
101+
trap 'cleanup' EXIT INT
101102

102103
# Disable remote GC operations
103104
for hostname in $hostnames; do

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ mkdir -p "$backup_dir"
5959
cleanup() {
6060
# Enable remote maintenance operations
6161
for hostname in $hostnames; do
62-
ghe-gc-enable $ssh_config_file_opt $hostname:$port || true
62+
ghe-gc-enable $ssh_config_file_opt $hostname:$port || {
63+
echo "Re-enable gc on $hostname failed, please manually delete $SYNC_IN_PROGRESS_FILE" 1>&2
64+
}
6365
done
6466

6567
ghe-ssh "$GHE_HOSTNAME" -- rm -rf $remote_tempdir

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,4 +93,10 @@ ghe-ssh -p "$port" "$host" -- ghe-actions-console -s mps -c "Repair-DatabaseLogi
9393
ghe-ssh -p "$port" "$host" -- ghe-actions-console -s token -c "Repair-DatabaseLogins"
9494
ghe-ssh -p "$port" "$host" -- ghe-actions-console -s actions -c "Repair-DatabaseLogins"
9595

96+
if [ ! -z "$(find "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/mssql/" -maxdepth 1 -name 'ArtifactCache_Configuration*.bak')" ]; then
97+
ghe-ssh -p "$port" "$host" -- ghe-actions-console -s artifactcache -c "Repair-DatabaseLogins"
98+
else
99+
echo "ArtifactCache is not present in mssql backup. Skipping Repair-DatabaseLogins for it."
100+
fi
101+
96102
bm_end "$(basename $0)"

share/github-backup-utils/version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.3.1
1+
3.4.0

test/bin/ghe-redis-cli

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ while true; do
1818
echo "fake redis data" > "$GHE_REMOTE_DATA_USER_DIR/redis/dump.rdb"
1919
break
2020
;;
21+
mset)
22+
# Fake accepting of mset command
23+
shift 9
24+
break
25+
;;
2126
--remote)
2227
# Fake accepting hostname argument
2328
shift 3

test/test-ghe-host-check.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ begin_test "ghe-host-check detects unsupported GitHub Enterprise Server versions
6161
! GHE_TEST_REMOTE_VERSION=2.21.0 ghe-host-check
6262
! GHE_TEST_REMOTE_VERSION=2.22.0 ghe-host-check
6363
! GHE_TEST_REMOTE_VERSION=3.0.0 ghe-host-check
64-
GHE_TEST_REMOTE_VERSION=3.1.0 ghe-host-check
64+
! GHE_TEST_REMOTE_VERSION=3.1.0 ghe-host-check
65+
GHE_TEST_REMOTE_VERSION=3.2.0 ghe-host-check
6566
GHE_TEST_REMOTE_VERSION=$BACKUP_UTILS_VERSION ghe-host-check
6667
GHE_TEST_REMOTE_VERSION=$BACKUP_UTILS_VERSION ghe-host-check
6768
GHE_TEST_REMOTE_VERSION=$bu_version_major.$bu_version_minor.999 ghe-host-check

0 commit comments

Comments
 (0)