@@ -123,7 +123,7 @@ cleanup () {
123
123
# Cleanup SSH multiplexing
124
124
ghe-ssh --clean
125
125
# Remove in-progress file
126
- ghe_restore_finished
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.
@@ -154,6 +154,25 @@ cleanup_cluster_nodes() {
154
154
# Check to make sure moreutils parallel is installed and working properly
155
155
ghe_parallel_check
156
156
157
+ # ghe_restore_check
158
+ if [ -h ${GHE_DATA_DIR} /.in-progress-restore ]; then
159
+ echo " Error: detected a restore already in progress from a previous version of ghe-restore." 1>&2
160
+ echo " If there is no restore in progress anymore, please remove" 1>&2
161
+ echo " the $GHE_DATA_DIR /in-progress-restore file." 1>&2
162
+ exit 1
163
+ fi
164
+
165
+ echo " ${GHE_DATA_DIR} /.in-progress-restore"
166
+ if [ -f ${GHE_DATA_DIR} /.in-progress-restore ]; then
167
+ progress=$( cat ${GHE_DATA_DIR} /.in-progress-restore)
168
+ snapshot=$( echo " $progress " | cut -d ' ' -f 1)
169
+ pid=$( echo " $progress " | cut -d ' ' -f 2)
170
+ echo " Error: A restore of $GHE_HOSTNAME may still be running on PID $pid ." 1>&2
171
+ echo " If PID $pid is not a process related to the restore utilities, please remove" 1>&2
172
+ echo " the $GHE_DATA_DIR /in-progress-restore file and try again." 1>&2
173
+ exit 1
174
+ fi
175
+
157
176
# Check to make sure a restore or backup is not in progress
158
177
159
178
@@ -175,8 +194,23 @@ GHE_RESTORE_SNAPSHOT_PATH="$(ghe-restore-snapshot-path "$snapshot_id")"
175
194
GHE_RESTORE_SNAPSHOT=$( basename " $GHE_RESTORE_SNAPSHOT_PATH " )
176
195
export GHE_RESTORE_SNAPSHOT
177
196
178
- ghe_backup_check
179
- ghe_restore_check
197
+ # ghe_backup_check
198
+ if [ -h ${GHE_DATA_DIR} /.in-progress ]; then
199
+ echo " Error: detected a backup already in progress from a previous version of ghe-backup." 1>&2
200
+ echo " If there is no backup in progress anymore, please remove" 1>&2
201
+ echo " the $GHE_DATA_DIR /.in-progress-backup file." 1>&2
202
+ exit 1
203
+ fi
204
+
205
+ if [ -f ${GHE_DATA_DIR} /.in-progress ]; then
206
+ progress=$( cat ${GHE_DATA_DIR} /.in-progress)
207
+ snapshot=$( echo " $progress " | cut -d ' ' -f 1)
208
+ pid=$( echo " $progress " | cut -d ' ' -f 2)
209
+ echo " Error: A backup of $GHE_HOSTNAME may still be running on PID $pid ." 1>&2
210
+ echo " If PID $pid is not a process related to the backup utilities, please remove" 1>&2
211
+ echo " the $GHE_DATA_DIR /.in-progress file and try again." 1>&2
212
+ exit 1
213
+ fi
180
214
181
215
# Detect if the backup we are restoring has a leaked ssh key
182
216
echo " Checking for leaked keys in the backup snapshot that is being restored ..."
@@ -260,8 +294,13 @@ START_TIME=$(date +%s)
260
294
echo ' Start time:' $START_TIME
261
295
echo " Starting restore of $GHE_HOSTNAME with backup-utils v$BACKUP_UTILS_VERSION from snapshot $GHE_RESTORE_SNAPSHOT "
262
296
ghe_remote_logger " Starting restore from $( hostname) with backup-utils v$BACKUP_UTILS_VERSION / snapshot $GHE_RESTORE_SNAPSHOT ..."
263
- ghe_restore_started $START_TIME
297
+ # Create an in-progress-restore file to prevent simultaneous backup or restore runs
298
+ echo " ${START_TIME} $$ " > ${GHE_DATA_DIR} /.in-progress-restore
264
299
300
+ sleep 120
301
+ rm -f ${GHE_DATA_DIR} /.in-progress-restore
302
+ echo " finished with fake restore"
303
+ exit 1
265
304
# Keep other processes on the VM or cluster in the loop about the restore status.
266
305
#
267
306
# Other processes will look for these states:
@@ -588,7 +627,7 @@ echo 'End time:' $END_TIME
588
627
echo ' Runtime:' $(( $END_TIME - $START_TIME )) ' seconds'
589
628
590
629
echo " Restore of $GHE_HOSTNAME from snapshot $GHE_RESTORE_SNAPSHOT finished."
591
- ghe_restore_finished
630
+ rm -f ${GHE_DATA_DIR} /.in-progress-restore
592
631
593
632
if ! $instance_configured ; then
594
633
echo " To complete the restore process, please visit https://$hostname /setup/settings to review and save the appliance configuration."
0 commit comments