32
32
set -e
33
33
34
34
# Parse arguments
35
- : ${RESTORE_SETTINGS:= false}
35
+ : " ${RESTORE_SETTINGS:= false} "
36
36
export RESTORE_SETTINGS
37
37
38
- : ${FORCE:= false}
38
+ : " ${FORCE:= false} "
39
39
export FORCE
40
40
41
- : ${SKIP_MYSQL:= false}
41
+ : " ${SKIP_MYSQL:= false} "
42
42
export SKIP_MYSQL
43
43
44
44
while true ; do
@@ -123,7 +123,7 @@ cleanup () {
123
123
# Cleanup SSH multiplexing
124
124
ghe-ssh --clean
125
125
# Remove in-progress file
126
- rm -f ${GHE_DATA_DIR} /in-progress-restore
126
+ rm -f " ${GHE_DATA_DIR} /in-progress-restore"
127
127
}
128
128
129
129
# This function's type definition is being passed to a remote host via `ghe-ssh` but is not used locally.
@@ -135,16 +135,16 @@ cleanup_cluster_nodes() {
135
135
exit 2
136
136
fi
137
137
138
- ghe-spokes server evacuate git-server-$uuid ' Removing replica'
139
- ghe-spokes server destroy git-server-$uuid
138
+ ghe-spokes server evacuate " git-server-$uuid " ' Removing replica'
139
+ ghe-spokes server destroy " git-server-$uuid "
140
140
141
- ghe-storage destroy-host storage-server-$uuid --force
141
+ ghe-storage destroy-host " storage-server-$uuid " --force
142
142
143
- ghe-dpages offline pages-server-$uuid
144
- ghe-dpages remove pages-server-$uuid
143
+ ghe-dpages offline " pages-server-$uuid "
144
+ ghe-dpages remove " pages-server-$uuid "
145
145
146
- ghe-redis-cli del resque:queue:maint_git-server-$uuid
147
- ghe-redis-cli srem resque:queues maint_git-server-$uuid
146
+ ghe-redis-cli del " resque:queue:maint_git-server-$uuid "
147
+ ghe-redis-cli srem resque:queues " maint_git-server-$uuid "
148
148
}
149
149
150
150
# Bring in the backup configuration
257
257
258
258
# Log restore start message locally and in /var/log/syslog on remote instance
259
259
START_TIME=$( date +%s)
260
- echo ' Start time:' $START_TIME
260
+ echo " Start time: $START_TIME "
261
261
echo " Starting restore of $GHE_HOSTNAME with backup-utils v$BACKUP_UTILS_VERSION from snapshot $GHE_RESTORE_SNAPSHOT "
262
262
ghe_remote_logger " Starting restore from $( hostname) with backup-utils v$BACKUP_UTILS_VERSION / snapshot $GHE_RESTORE_SNAPSHOT ..."
263
263
# Create an in-progress-restore file to prevent simultaneous backup or restore runs
264
- echo " ${START_TIME} $$ " > ${GHE_DATA_DIR} /in-progress-restore
264
+ echo " ${START_TIME} $$ " > " ${GHE_DATA_DIR} /in-progress-restore"
265
265
266
266
# Keep other processes on the VM or cluster in the loop about the restore status.
267
267
#
@@ -297,7 +297,7 @@ RELEASE_VERSION=$(ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --get core.package-vers
297
297
298
298
# If the backup being restored is from an appliance with Actions disabled, restoring it onto an appliance with Actions enabled will cause
299
299
# mismatches in the secrets needed for Actions which ultimately results in Actions not working properly. Note: xargs is to remove whitespace
300
- ACTIONS_ENABLED_IN_BACKUP=$( git config -f $GHE_RESTORE_SNAPSHOT_PATH /settings.json --bool app.actions.enabled | xargs)
300
+ ACTIONS_ENABLED_IN_BACKUP=$( git config -f " $GHE_RESTORE_SNAPSHOT_PATH /settings.json" --bool app.actions.enabled | xargs)
301
301
if [[ $ACTIONS_ENABLED_IN_BACKUP != true ]] && ghe-ssh " $GHE_HOSTNAME " -- ' ghe-config --true app.actions.enabled' ; then
302
302
echo " Error: Restoring a backup with Actions disabled onto an appliance with Actions enabled is not supported." >&2
303
303
exit 1
388
388
# Restore UUID if present and not restoring to cluster.
389
389
if [ -s " $GHE_RESTORE_SNAPSHOT_PATH /uuid" ] && ! $CLUSTER ; then
390
390
echo " Restoring UUID ..."
391
- cat " $GHE_RESTORE_SNAPSHOT_PATH /uuid" |
392
- ghe-ssh " $GHE_HOSTNAME " -- " sudo sponge '$GHE_REMOTE_DATA_USER_DIR /common/uuid' 2>/dev/null"
391
+ ghe-ssh " $GHE_HOSTNAME " -- " sudo sponge '$GHE_REMOTE_DATA_USER_DIR /common/uuid' 2>/dev/null" < " $GHE_RESTORE_SNAPSHOT_PATH /uuid"
393
392
ghe-ssh " $GHE_HOSTNAME " -- " sudo systemctl stop consul" || true
394
393
ghe-ssh " $GHE_HOSTNAME " -- " sudo rm -rf /data/user/consul/raft"
395
- fi
394
+ fi
396
395
397
396
if is_external_database_snapshot; then
398
397
appliance_strategy=" external"
@@ -474,13 +473,13 @@ if ! $CLUSTER && [ -d "$GHE_RESTORE_SNAPSHOT_PATH/elasticsearch" ]; then
474
473
fi
475
474
476
475
# Restore the audit log migration sentinel file, if it exists in the snapshot
477
- if test -f $GHE_RESTORE_SNAPSHOT_PATH /es-scan-complete; then
476
+ if test -f " $GHE_RESTORE_SNAPSHOT_PATH /es-scan-complete" ; then
478
477
ghe-ssh " $GHE_HOSTNAME " -- " sudo touch $GHE_REMOTE_DATA_USER_DIR /common/es-scan-complete"
479
478
fi
480
479
481
480
# Restore exported audit logs to 2.12.9 and newer single nodes and
482
481
# all releases of cluster
483
- if $CLUSTER || [ " $( version $GHE_REMOTE_VERSION ) " -ge " $( version 2.12.9) " ]; then
482
+ if $CLUSTER || [ " $( version " $GHE_REMOTE_VERSION " ) " -ge " $( version 2.12.9) " ]; then
484
483
if [[ " $GHE_RESTORE_SKIP_AUDIT_LOGS " = " yes" ]]; then
485
484
echo " Skipping restore of audit logs."
486
485
else
@@ -492,7 +491,7 @@ if $CLUSTER || [ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 2.12.9)" ]; the
492
491
fi
493
492
494
493
if [ " $GHE_PARALLEL_ENABLED " = " yes" ]; then
495
- $GHE_PARALLEL_COMMAND $ GHE_PARALLEL_COMMAND_OPTIONS -- " ${commands[@]} "
494
+ " $GHE_PARALLEL_COMMAND " " ${ GHE_PARALLEL_COMMAND_OPTIONS[@]} " -- " ${commands[@]} "
496
495
else
497
496
for c in " ${commands[@]} " ; do
498
497
eval " $c "
@@ -545,7 +544,7 @@ CRON_RUNNING=true
545
544
546
545
# Clean up all stale replicas on configured instances.
547
546
if ! $CLUSTER && $instance_configured ; then
548
- restored_uuid=$( cat $GHE_RESTORE_SNAPSHOT_PATH /uuid)
547
+ restored_uuid=$( cat " $GHE_RESTORE_SNAPSHOT_PATH /uuid" )
549
548
other_nodes=$( echo "
550
549
set -o pipefail; \
551
550
ghe-spokes server show --json \
585
584
fi
586
585
587
586
END_TIME=$( date +%s)
588
- echo ' End time:' $END_TIME
589
- echo ' Runtime:' $(( $ END_TIME - $ START_TIME)) ' seconds'
587
+ echo " End time: $END_TIME "
588
+ echo " Runtime: $(( END_TIME - START_TIME)) seconds"
590
589
591
590
echo " Restore of $GHE_HOSTNAME from snapshot $GHE_RESTORE_SNAPSHOT finished."
592
591
ghe_restore_finished
0 commit comments