Skip to content

Commit c60f08f

Browse files
committed
Revert "Always restore Actions settings"
This reverts commit bb4fab1.
1 parent bb4fab1 commit c60f08f

File tree

6 files changed

+34
-39
lines changed

6 files changed

+34
-39
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ if [ -d "$GHE_DATA_DIR/current/actions" ] && [ "$(ls -A $GHE_DATA_DIR/current/ac
3737
fi
3838

3939
# Transfer all Actions data from the user data directory using rsync.
40-
ghe_verbose "* Transferring Actions files from $host ..."
40+
ghe_verbose "* Transferring actions files from $host ..."
4141

4242
ghe-rsync -avz \
4343
-e "ghe-ssh -p $port" \

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

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -477,13 +477,3 @@ prompt_for_confirmation(){
477477

478478
echo
479479
}
480-
481-
# Function to restore a secret setting stored in a file.
482-
# restore-secret <description> <file-name> <setting-name>
483-
restore-secret() {
484-
if [ -f "$GHE_RESTORE_SNAPSHOT_PATH/$2" ]; then
485-
echo "Restoring $1 ..."
486-
echo "ghe-config '$3' '$(cat "$GHE_RESTORE_SNAPSHOT_PATH/$2")'" |
487-
ghe-ssh "$GHE_HOSTNAME" -- /bin/bash
488-
fi
489-
}

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

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,11 @@ GHE_HOSTNAME="$1"
2222
# us run this script directly.
2323
: ${GHE_RESTORE_SNAPSHOT:=current}
2424

25-
# Path to snapshot dir we're restoring from
26-
GHE_RESTORE_SNAPSHOT_PATH="$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT"
27-
2825
port=$(ssh_port_part "$GHE_HOSTNAME")
2926
host=$(ssh_host_part "$GHE_HOSTNAME")
3027

3128
# No need to restore anything, early exit
32-
if [ ! -d "$GHE_RESTORE_SNAPSHOT_PATH/actions" ]; then
29+
if [ ! -d "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/actions" ]; then
3330
echo "Warning: Actions backup missing. Skipping ..."
3431
exit 0
3532
fi
@@ -38,35 +35,15 @@ fi
3835
ghe_remote_version_required "$host"
3936

4037
# Transfer all Actions data from the snapshot to the user data directory using rsync.
41-
ghe_verbose "* Transferring Actions files to $host ..."
38+
ghe_verbose "* Transferring actions files to $host ..."
4239

4340
echo "sudo mkdir -p $GHE_REMOTE_DATA_USER_DIR/actions" |
4441
ghe-ssh -p $port $host /bin/bash
4542

4643
ghe-rsync -arvHR --delete \
4744
-e "ghe-ssh -p $port" \
4845
--rsync-path='sudo -u actions rsync' \
49-
"$GHE_RESTORE_SNAPSHOT_PATH/actions/./" \
46+
"$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/actions/./" \
5047
"$host:$GHE_REMOTE_DATA_USER_DIR/actions/" 1>&3
5148

52-
# Restore Actions settings.
53-
ghe_verbose "* Restoring Actions settings to $host ..."
54-
55-
restore-secret "Actions configuration database login" "actions-config-db-login" "secrets.actions.ConfigurationDatabaseSqlLogin"
56-
restore-secret "Actions configuration database password" "actions-config-db-password" "secrets.actions.ConfigurationDatabaseSqlPassword"
57-
restore-secret "Actions framework access token key secret" "actions-framework-access-token" "secrets.actions.FrameworkAccessTokenKeySecret"
58-
restore-secret "Actions Url signing HMAC key primary" "actions-url-signing-hmac-key-primary" "secrets.actions.UrlSigningHmacKeyPrimary"
59-
restore-secret "Actions Url signing HMAC key secondary" "actions-url-signing-hmac-key-secondary" "secrets.actions.UrlSigningHmacKeySecondary"
60-
restore-secret "Actions OAuth S2S signing cert" "actions-oauth-s2s-signing-cert" "secrets.actions.OAuthS2SSigningCert"
61-
restore-secret "Actions OAuth S2S signing key" "actions-oauth-s2s-signing-key" "secrets.actions.OAuthS2SSigningKey"
62-
restore-secret "Actions OAuth S2S signing cert thumbprint" "actions-oauth-s2s-signing-cert-thumbprint" "secrets.actions.OAuthS2SSigningCertThumbprint"
63-
restore-secret "Actions primary encryption cert thumbprint" "actions-primary-encryption-cert-thumbprint" "secrets.actions.PrimaryEncryptionCertificateThumbprint"
64-
restore-secret "Actions AAD cert thumbprint" "actions-aad-cert-thumbprint" "secrets.actions.AADCertThumbprint"
65-
restore-secret "Actions delegated auth cert thumbprint" "actions-delegated-auth-cert-thumbprint" "secrets.actions.DelegatedAuthCertThumbprint"
66-
restore-secret "Actions runtime service principal cert" "actions-runtime-service-principal-cert" "secrets.actions.RuntimeServicePrincipalCertificate"
67-
restore-secret "Actions S2S encryption cert" "actions-s2s-encryption-cert" "secrets.actions.S2SEncryptionCertificate"
68-
restore-secret "Actions secondary encryption cert thumbprint" "actions-secondary-encryption-cert-thumbprint" "secrets.actions.SecondaryEncryptionCertificateThumbprint"
69-
restore-secret "Actions service principal cert" "actions-service-principal-cert" "secrets.actions.ServicePrincipalCertificate"
70-
restore-secret "Actions SPS validation cert thumbprint" "actions-sps-validation-cert-thumbprint" "secrets.actions.SpsValidationCertThumbprint"
71-
7249
bm_end "$(basename $0)"

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

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,39 @@ GHE_RESTORE_SNAPSHOT_PATH="$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT"
2828
echo "Restoring license ..."
2929
ghe-ssh "$GHE_HOSTNAME" -- 'ghe-import-license' < "$GHE_RESTORE_SNAPSHOT_PATH/enterprise.ghl" 1>&3
3030

31+
# Function to restore a secret setting stored in a file.
32+
# restore-secret <description> <file-name> <setting-name>
33+
restore-secret() {
34+
if [ -f "$GHE_RESTORE_SNAPSHOT_PATH/$2" ]; then
35+
echo "Restoring $1 ..."
36+
echo "ghe-config '$3' '$(cat "$GHE_RESTORE_SNAPSHOT_PATH/$2")'" |
37+
ghe-ssh "$GHE_HOSTNAME" -- /bin/bash
38+
fi
39+
}
40+
3141
echo "Restoring settings ..."
3242

3343
# Restore external MySQL password if running external MySQL DB.
3444
restore-secret "external MySQL password" "external-mysql-password" "secrets.external.mysql"
3545

46+
# Restore Actions settings.
47+
restore-secret "Actions configuration database login" "actions-config-db-login" "secrets.actions.ConfigurationDatabaseSqlLogin"
48+
restore-secret "Actions configuration database password" "actions-config-db-password" "secrets.actions.ConfigurationDatabaseSqlPassword"
49+
restore-secret "Actions framework access token key secret" "actions-framework-access-token" "secrets.actions.FrameworkAccessTokenKeySecret"
50+
restore-secret "Actions Url signing HMAC key primary" "actions-url-signing-hmac-key-primary" "secrets.actions.UrlSigningHmacKeyPrimary"
51+
restore-secret "Actions Url signing HMAC key secondary" "actions-url-signing-hmac-key-secondary" "secrets.actions.UrlSigningHmacKeySecondary"
52+
restore-secret "Actions OAuth S2S signing cert" "actions-oauth-s2s-signing-cert" "secrets.actions.OAuthS2SSigningCert"
53+
restore-secret "Actions OAuth S2S signing key" "actions-oauth-s2s-signing-key" "secrets.actions.OAuthS2SSigningKey"
54+
restore-secret "Actions OAuth S2S signing cert thumbprint" "actions-oauth-s2s-signing-cert-thumbprint" "secrets.actions.OAuthS2SSigningCertThumbprint"
55+
restore-secret "Actions primary encryption cert thumbprint" "actions-primary-encryption-cert-thumbprint" "secrets.actions.PrimaryEncryptionCertificateThumbprint"
56+
restore-secret "Actions AAD cert thumbprint" "actions-aad-cert-thumbprint" "secrets.actions.AADCertThumbprint"
57+
restore-secret "Actions delegated auth cert thumbprint" "actions-delegated-auth-cert-thumbprint" "secrets.actions.DelegatedAuthCertThumbprint"
58+
restore-secret "Actions runtime service principal cert" "actions-runtime-service-principal-cert" "secrets.actions.RuntimeServicePrincipalCertificate"
59+
restore-secret "Actions S2S encryption cert" "actions-s2s-encryption-cert" "secrets.actions.S2SEncryptionCertificate"
60+
restore-secret "Actions secondary encryption cert thumbprint" "actions-secondary-encryption-cert-thumbprint" "secrets.actions.SecondaryEncryptionCertificateThumbprint"
61+
restore-secret "Actions service principal cert" "actions-service-principal-cert" "secrets.actions.ServicePrincipalCertificate"
62+
restore-secret "Actions SPS validation cert thumbprint" "actions-sps-validation-cert-thumbprint" "secrets.actions.SpsValidationCertThumbprint"
63+
3664
# work around issue importing settings with bad storage mode values
3765
( cat "$GHE_RESTORE_SNAPSHOT_PATH/settings.json" && echo ) |
3866
sed 's/"storage_mode": "device"/"storage_mode": "rootfs"/' |

test/test-ghe-backup.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ begin_test "ghe-backup takes backup of Actions files"
490490
enable_actions
491491

492492
output=$(ghe-backup -v)
493-
echo $output | grep "Transferring Actions files from"
493+
echo $output | grep "Transferring actions files from"
494494

495495
diff -ru "$GHE_REMOTE_DATA_USER_DIR/actions" "$GHE_DATA_DIR/current/actions"
496496
)

test/test-ghe-restore.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ begin_test "ghe-restore with Actions data"
377377

378378
output=$(ghe-restore -v -f localhost 2>&1)
379379

380-
echo "$output" | grep -q "Transferring Actions files to"
380+
echo "$output" | grep -q "Transferring actions files to"
381381

382382
diff -ru "$GHE_REMOTE_DATA_USER_DIR/actions" "$GHE_DATA_DIR/current/actions"
383383
)

0 commit comments

Comments
 (0)