Skip to content

Commit 849b477

Browse files
committed
restore all the old logging statements.
1 parent db19e98 commit 849b477

File tree

1 file changed

+37
-24
lines changed

1 file changed

+37
-24
lines changed

bin/ghe-restore

Lines changed: 37 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -441,94 +441,106 @@ if ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.minio.enabled'; then
441441
ghe-restore-minio "$GHE_HOSTNAME" 1>&3
442442
fi
443443

444+
# log input into a variable for the parallel command, as the functions don't work with eval
445+
cmd_title=$(log_info "Restoring Redis database ...")
444446
commands=("
445-
echo \"Restoring Redis database ...\"
447+
echo \"$cmd_title\"
446448
ghe-ssh \"$GHE_HOSTNAME\" -- 'ghe-import-redis' < \"$GHE_RESTORE_SNAPSHOT_PATH/redis.rdb\" 1>&3")
447449

450+
cmd_title=$(log_info "Restoring Git Repositories ...")
448451
commands+=("
449-
echo \"Restoring Git repositories ...\"
452+
echo \"$cmd_title\"
450453
ghe-restore-repositories \"$GHE_HOSTNAME\"")
451454

455+
cmd_title=$(log_info "Restoring Gists ...")
452456
commands+=("
453-
echo \"Restoring Gists ...\"
457+
echo \"$cmd_title\"
454458
ghe-restore-repositories-gist \"$GHE_HOSTNAME\"")
455459

460+
cmd_title=$(log_info "Restoring Pages ...")
456461
commands+=("
457-
echo \"Restoring GitHub Pages artifacts ...\"
462+
echo \"$cmd_title\"
458463
ghe-restore-pages \"$GHE_HOSTNAME\" 1>&3")
459464

465+
cmd_title=$(log_info "Restoring SSH authorized keys ...")
460466
commands+=("
461-
echo \"Restoring SSH authorized keys ...\"
467+
echo \"$cmd_title\"
462468
ghe-ssh \"$GHE_HOSTNAME\" -- 'ghe-import-authorized-keys' < \"$GHE_RESTORE_SNAPSHOT_PATH/authorized-keys.json\" 1>&3")
463469

470+
cmd_title=$(log_info "Restoring storage data ...")
464471
commands+=("
465-
echo \"Restoring storage data ...\"
472+
echo \"$cmd_title\"
466473
ghe-restore-storage \"$GHE_HOSTNAME\" 1>&3")
467474

475+
cmd_title=$(log_info "Restoring custom Git hooks ...")
468476
commands+=("
469-
echo \"Restoring custom Git hooks ...\"
477+
echo \"$cmd_title\"
470478
ghe-restore-git-hooks \"$GHE_HOSTNAME\" 1>&3")
471479

472480
if ! $CLUSTER && [ -d "$GHE_RESTORE_SNAPSHOT_PATH/elasticsearch" ]; then
481+
cmd_title=$(log_info "Restoring Elasticsearch indices ...")
473482
commands+=("
474-
echo \"Restoring Elasticsearch indices ...\"
483+
echo \"cmd_title\"
475484
ghe-restore-es-rsync \"$GHE_HOSTNAME\" 1>&3")
476485
fi
477486

478487
# Restore the audit log migration sentinel file, if it exists in the snapshot
479488
if test -f "$GHE_RESTORE_SNAPSHOT_PATH"/es-scan-complete; then
480-
echo "Restoring Elasticsearch audit log migration sentinel file ..." 1>&3
481-
ghe-ssh "$GHE_HOSTNAME" -- "sudo touch $GHE_REMOTE_DATA_USER_DIR/common/es-scan-complete"
489+
log_info "Restoring Elasticsearch audit log migration sentinel file ..." 1>&3
490+
if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo touch $GHE_REMOTE_DATA_USER_DIR/common/es-scan-complete" ; then
491+
log_info "Failed to restore Elasticsearch audit log migration sentinel file." 1>&3
492+
fi
482493
fi
483494

484495
# Restore exported audit logs to 2.12.9 and newer single nodes and
485496
# all releases of cluster
486497
if $CLUSTER || [ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 2.12.9)" ]; then
487498
if [[ "$GHE_RESTORE_SKIP_AUDIT_LOGS" = "yes" ]]; then
488-
echo "Skipping restore of audit logs."
499+
log_info "Skipping restore of audit logs."
489500
else
501+
cmd_title=$(log_info "Restoring Audit logs ...")
490502
commands+=("
491-
echo \"Restoring Audit logs ...\"
503+
echo \"$cmd_title\"
492504
ghe-restore-es-audit-log \"$GHE_HOSTNAME\" 1>&3")
493505
fi
494506

495507
fi
496508

497509
if [ "$GHE_PARALLEL_ENABLED" = "yes" ]; then
498-
echo "Restoring data in parallel ..."
510+
log_info "Restoring data in parallel ..."
499511
$GHE_PARALLEL_COMMAND $GHE_PARALLEL_COMMAND_OPTIONS -- "${commands[@]}"
500512
else
501-
echo "Restoring data serially ..." 1>&3
513+
log_info "Restoring data serially ..." 1>&3
502514
for c in "${commands[@]}"; do
503515
eval "$c"
504516
done
505517
fi
506518

507519
# Restart an already running memcached to reset the cache after restore
508-
echo "Restarting memcached ..." 1>&3
520+
log_info "Restarting memcached ..." 1>&3
509521
echo "sudo restart -q memcached 2>/dev/null || true" |
510522
ghe-ssh "$GHE_HOSTNAME" -- /bin/sh
511523

512524
# Prevent GitHub Connect jobs running before we've had a chance to reset
513525
# the configuration by setting the last run date to now.
514526
if ! $RESTORE_SETTINGS; then
515-
echo "Setting last run date for GitHub Connect jobs ..." 1>&3
527+
log_info "Setting last run date for GitHub Connect jobs ..." 1>&3
516528
echo "now=$(date +%s.0000000); ghe-redis-cli mset timer:UpdateConnectInstallationInfo \$now timer:UploadEnterpriseServerUserAccountsJob \$now timer:UploadConnectMetricsJob \$now timer:GitHubConnectPushNewContributionsJob \$now" |
517529
ghe-ssh "$GHE_HOSTNAME" -- /bin/sh 1>&3
518530
fi
519531

520532
# When restoring to a host that has already been configured, kick off a
521533
# config run to perform data migrations.
522534
if $CLUSTER; then
523-
echo "Configuring cluster ..."
535+
log_info "Configuring cluster ..."
524536
if [ "$GHE_VERSION_MAJOR" -eq "3" ]; then
525537
ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-nomad-cleanup" 1>&3 2>&3
526538
elif [ "$GHE_VERSION_MAJOR" -eq "2" ] && [ "$GHE_VERSION_MINOR" -eq "22" ]; then
527539
ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- /usr/local/share/enterprise/ghe-nomad-cleanup" 1>&3 2>&3
528540
fi
529541
ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-config-apply" 1>&3 2>&3
530542
elif $instance_configured; then
531-
echo "Configuring appliance ..."
543+
log_info "Configuring appliance ..."
532544
if [ "$GHE_VERSION_MAJOR" -eq "3" ]; then
533545
ghe-ssh "$GHE_HOSTNAME" -- "ghe-nomad-cleanup" 1>&3 2>&3
534546
elif [ "$GHE_VERSION_MAJOR" -eq "2" ] && [ "$GHE_VERSION_MINOR" -eq "22" ]; then
@@ -540,6 +552,7 @@ fi
540552
# Clear GitHub Connect settings stored in the restored database.
541553
# This needs to happen after `ghe-config-apply` to ensure all migrations have run.
542554
if ! $RESTORE_SETTINGS; then
555+
log_info "Clearing GitHub Connect settings ..." 1>&3
543556
echo "if [ -f /usr/local/share/enterprise/ghe-reset-gh-connect ]; then /usr/local/share/enterprise/ghe-reset-gh-connect -y; fi" |
544557
ghe-ssh "$GHE_HOSTNAME" -- /bin/sh 1>&3
545558
fi
@@ -550,7 +563,7 @@ CRON_RUNNING=true
550563

551564
# Clean up all stale replicas on configured instances.
552565
if ! $CLUSTER && $instance_configured; then
553-
echo "Cleaning up replicas..." 1>&3
566+
log_info "Cleaning up replicas..." 1>&3
554567
restored_uuid=$(cat $GHE_RESTORE_SNAPSHOT_PATH/uuid)
555568
other_nodes=$(echo "
556569
set -o pipefail; \
@@ -560,7 +573,7 @@ if ! $CLUSTER && $instance_configured; then
560573
| ( grep -F -x -v \"$restored_uuid\" || true )" \
561574
| ghe-ssh "$GHE_HOSTNAME" -- /bin/bash)
562575
if [ -n "$other_nodes" ]; then
563-
echo "Cleaning up stale nodes ..."
576+
log_info "Cleaning up stale nodes ..."
564577
for uuid in $other_nodes; do
565578
# shellcheck disable=SC2034
566579
echo "set -o pipefail; $(typeset -f cleanup_cluster_nodes); cleanup_cluster_nodes $uuid" | ghe-ssh "$GHE_HOSTNAME" 1>&3
@@ -578,21 +591,21 @@ update_restore_status "complete"
578591
ghe_remote_logger "Completed restore from $(hostname) / snapshot ${GHE_RESTORE_SNAPSHOT}."
579592

580593
if ! $CLUSTER; then
581-
echo "Restoring SSH host keys ..."
594+
log_info "Restoring SSH host keys ..."
582595
ghe-ssh "$GHE_HOSTNAME" -- 'ghe-import-ssh-host-keys' < "$GHE_RESTORE_SNAPSHOT_PATH/ssh-host-keys.tar" 1>&3
583596
else
584597
# This will make sure that Git over SSH host keys (babeld) are
585598
# copied to all the cluster nodes so babeld uses the same keys.
586-
echo "Restoring Git over SSH host keys ..."
599+
log_info "Restoring Git over SSH host keys ..."
587600
ghe-ssh "$GHE_HOSTNAME" -- "sudo tar -xpf - -C $GHE_REMOTE_DATA_USER_DIR/common" < "$GHE_RESTORE_SNAPSHOT_PATH/ssh-host-keys.tar" 1>&3
588601
ghe-ssh "$GHE_HOSTNAME" -- "sudo chown babeld:babeld $GHE_REMOTE_DATA_USER_DIR/common/ssh_host_*" 1>&3
589602
echo "if [ -f /usr/local/share/enterprise/ghe-cluster-config-update ]; then /usr/local/share/enterprise/ghe-cluster-config-update -s; else ghe-cluster-config-update -s; fi" |
590603
ghe-ssh "$GHE_HOSTNAME" -- /bin/sh 1>&3
591604
fi
592605

593606
END_TIME=$(date +%s)
594-
echo "Runtime: $((${END_TIME} - ${START_TIME})) seconds"
595-
echo "Restore of $GHE_HOSTNAME from snapshot $GHE_RESTORE_SNAPSHOT finished."
607+
log_info "Runtime: $((${END_TIME} - ${START_TIME})) seconds"
608+
log_info "Restore of $GHE_HOSTNAME from snapshot $GHE_RESTORE_SNAPSHOT finished."
596609

597610

598611
if ! $instance_configured; then

0 commit comments

Comments
 (0)