@@ -441,94 +441,106 @@ if ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.minio.enabled'; then
441
441
ghe-restore-minio " $GHE_HOSTNAME " 1>&3
442
442
fi
443
443
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 ..." )
444
446
commands=("
445
- echo \" Restoring Redis database ... \"
447
+ echo \" $cmd_title \"
446
448
ghe-ssh \" $GHE_HOSTNAME \" -- 'ghe-import-redis' < \" $GHE_RESTORE_SNAPSHOT_PATH /redis.rdb\" 1>&3" )
447
449
450
+ cmd_title=$( log_info " Restoring Git Repositories ..." )
448
451
commands+=("
449
- echo \" Restoring Git repositories ... \"
452
+ echo \" $cmd_title \"
450
453
ghe-restore-repositories \" $GHE_HOSTNAME \" " )
451
454
455
+ cmd_title=$( log_info " Restoring Gists ..." )
452
456
commands+=("
453
- echo \" Restoring Gists ... \"
457
+ echo \" $cmd_title \"
454
458
ghe-restore-repositories-gist \" $GHE_HOSTNAME \" " )
455
459
460
+ cmd_title=$( log_info " Restoring Pages ..." )
456
461
commands+=("
457
- echo \" Restoring GitHub Pages artifacts ... \"
462
+ echo \" $cmd_title \"
458
463
ghe-restore-pages \" $GHE_HOSTNAME \" 1>&3" )
459
464
465
+ cmd_title=$( log_info " Restoring SSH authorized keys ..." )
460
466
commands+=("
461
- echo \" Restoring SSH authorized keys ... \"
467
+ echo \" $cmd_title \"
462
468
ghe-ssh \" $GHE_HOSTNAME \" -- 'ghe-import-authorized-keys' < \" $GHE_RESTORE_SNAPSHOT_PATH /authorized-keys.json\" 1>&3" )
463
469
470
+ cmd_title=$( log_info " Restoring storage data ..." )
464
471
commands+=("
465
- echo \" Restoring storage data ... \"
472
+ echo \" $cmd_title \"
466
473
ghe-restore-storage \" $GHE_HOSTNAME \" 1>&3" )
467
474
475
+ cmd_title=$( log_info " Restoring custom Git hooks ..." )
468
476
commands+=("
469
- echo \" Restoring custom Git hooks ... \"
477
+ echo \" $cmd_title \"
470
478
ghe-restore-git-hooks \" $GHE_HOSTNAME \" 1>&3" )
471
479
472
480
if ! $CLUSTER && [ -d " $GHE_RESTORE_SNAPSHOT_PATH /elasticsearch" ]; then
481
+ cmd_title=$( log_info " Restoring Elasticsearch indices ..." )
473
482
commands+=("
474
- echo \" Restoring Elasticsearch indices ... \"
483
+ echo \" cmd_title \"
475
484
ghe-restore-es-rsync \" $GHE_HOSTNAME \" 1>&3" )
476
485
fi
477
486
478
487
# Restore the audit log migration sentinel file, if it exists in the snapshot
479
488
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
482
493
fi
483
494
484
495
# Restore exported audit logs to 2.12.9 and newer single nodes and
485
496
# all releases of cluster
486
497
if $CLUSTER || [ " $( version $GHE_REMOTE_VERSION ) " -ge " $( version 2.12.9) " ]; then
487
498
if [[ " $GHE_RESTORE_SKIP_AUDIT_LOGS " = " yes" ]]; then
488
- echo " Skipping restore of audit logs."
499
+ log_info " Skipping restore of audit logs."
489
500
else
501
+ cmd_title=$( log_info " Restoring Audit logs ..." )
490
502
commands+=("
491
- echo \" Restoring Audit logs ... \"
503
+ echo \" $cmd_title \"
492
504
ghe-restore-es-audit-log \" $GHE_HOSTNAME \" 1>&3" )
493
505
fi
494
506
495
507
fi
496
508
497
509
if [ " $GHE_PARALLEL_ENABLED " = " yes" ]; then
498
- echo " Restoring data in parallel ..."
510
+ log_info " Restoring data in parallel ..."
499
511
$GHE_PARALLEL_COMMAND $GHE_PARALLEL_COMMAND_OPTIONS -- " ${commands[@]} "
500
512
else
501
- echo " Restoring data serially ..." 1>&3
513
+ log_info " Restoring data serially ..." 1>&3
502
514
for c in " ${commands[@]} " ; do
503
515
eval " $c "
504
516
done
505
517
fi
506
518
507
519
# Restart an already running memcached to reset the cache after restore
508
- echo " Restarting memcached ..." 1>&3
520
+ log_info " Restarting memcached ..." 1>&3
509
521
echo " sudo restart -q memcached 2>/dev/null || true" |
510
522
ghe-ssh " $GHE_HOSTNAME " -- /bin/sh
511
523
512
524
# Prevent GitHub Connect jobs running before we've had a chance to reset
513
525
# the configuration by setting the last run date to now.
514
526
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
516
528
echo " now=$( date +%s.0000000) ; ghe-redis-cli mset timer:UpdateConnectInstallationInfo \$ now timer:UploadEnterpriseServerUserAccountsJob \$ now timer:UploadConnectMetricsJob \$ now timer:GitHubConnectPushNewContributionsJob \$ now" |
517
529
ghe-ssh " $GHE_HOSTNAME " -- /bin/sh 1>&3
518
530
fi
519
531
520
532
# When restoring to a host that has already been configured, kick off a
521
533
# config run to perform data migrations.
522
534
if $CLUSTER ; then
523
- echo " Configuring cluster ..."
535
+ log_info " Configuring cluster ..."
524
536
if [ " $GHE_VERSION_MAJOR " -eq " 3" ]; then
525
537
ghe-ssh " $GHE_HOSTNAME " -- " ghe-cluster-nomad-cleanup" 1>&3 2>&3
526
538
elif [ " $GHE_VERSION_MAJOR " -eq " 2" ] && [ " $GHE_VERSION_MINOR " -eq " 22" ]; then
527
539
ghe-ssh " $GHE_HOSTNAME " -- " ghe-cluster-each -- /usr/local/share/enterprise/ghe-nomad-cleanup" 1>&3 2>&3
528
540
fi
529
541
ghe-ssh " $GHE_HOSTNAME " -- " ghe-cluster-config-apply" 1>&3 2>&3
530
542
elif $instance_configured ; then
531
- echo " Configuring appliance ..."
543
+ log_info " Configuring appliance ..."
532
544
if [ " $GHE_VERSION_MAJOR " -eq " 3" ]; then
533
545
ghe-ssh " $GHE_HOSTNAME " -- " ghe-nomad-cleanup" 1>&3 2>&3
534
546
elif [ " $GHE_VERSION_MAJOR " -eq " 2" ] && [ " $GHE_VERSION_MINOR " -eq " 22" ]; then
540
552
# Clear GitHub Connect settings stored in the restored database.
541
553
# This needs to happen after `ghe-config-apply` to ensure all migrations have run.
542
554
if ! $RESTORE_SETTINGS ; then
555
+ log_info " Clearing GitHub Connect settings ..." 1>&3
543
556
echo " if [ -f /usr/local/share/enterprise/ghe-reset-gh-connect ]; then /usr/local/share/enterprise/ghe-reset-gh-connect -y; fi" |
544
557
ghe-ssh " $GHE_HOSTNAME " -- /bin/sh 1>&3
545
558
fi
@@ -550,7 +563,7 @@ CRON_RUNNING=true
550
563
551
564
# Clean up all stale replicas on configured instances.
552
565
if ! $CLUSTER && $instance_configured ; then
553
- echo " Cleaning up replicas..." 1>&3
566
+ log_info " Cleaning up replicas..." 1>&3
554
567
restored_uuid=$( cat $GHE_RESTORE_SNAPSHOT_PATH /uuid)
555
568
other_nodes=$( echo "
556
569
set -o pipefail; \
@@ -560,7 +573,7 @@ if ! $CLUSTER && $instance_configured; then
560
573
| ( grep -F -x -v \" $restored_uuid \" || true )" \
561
574
| ghe-ssh " $GHE_HOSTNAME " -- /bin/bash)
562
575
if [ -n " $other_nodes " ]; then
563
- echo " Cleaning up stale nodes ..."
576
+ log_info " Cleaning up stale nodes ..."
564
577
for uuid in $other_nodes ; do
565
578
# shellcheck disable=SC2034
566
579
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"
578
591
ghe_remote_logger " Completed restore from $( hostname) / snapshot ${GHE_RESTORE_SNAPSHOT} ."
579
592
580
593
if ! $CLUSTER ; then
581
- echo " Restoring SSH host keys ..."
594
+ log_info " Restoring SSH host keys ..."
582
595
ghe-ssh " $GHE_HOSTNAME " -- ' ghe-import-ssh-host-keys' < " $GHE_RESTORE_SNAPSHOT_PATH /ssh-host-keys.tar" 1>&3
583
596
else
584
597
# This will make sure that Git over SSH host keys (babeld) are
585
598
# 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 ..."
587
600
ghe-ssh " $GHE_HOSTNAME " -- " sudo tar -xpf - -C $GHE_REMOTE_DATA_USER_DIR /common" < " $GHE_RESTORE_SNAPSHOT_PATH /ssh-host-keys.tar" 1>&3
588
601
ghe-ssh " $GHE_HOSTNAME " -- " sudo chown babeld:babeld $GHE_REMOTE_DATA_USER_DIR /common/ssh_host_*" 1>&3
589
602
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" |
590
603
ghe-ssh " $GHE_HOSTNAME " -- /bin/sh 1>&3
591
604
fi
592
605
593
606
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."
596
609
597
610
598
611
if ! $instance_configured ; then
0 commit comments