Skip to content

Commit 14ccf9e

Browse files
committed
cleanup from review
1 parent d42ccdf commit 14ccf9e

File tree

3 files changed

+20
-16
lines changed

3 files changed

+20
-16
lines changed

bin/ghe-backup

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ ghe_restore_check
123123
if [ -h ../in-progress ]; then
124124
echo "Error: detected a backup already in progress from a previous version of ghe-backup." 1>&2
125125
echo "If there is no backup in progress anymore, please remove" 1>&2
126-
echo "the \"$GHE_DATA_DIR/in-progress\" file and try again." 1>&2
126+
echo "the $GHE_DATA_DIR/in-progress file and try again." 1>&2
127127
exit 1
128128
fi
129129

@@ -139,12 +139,13 @@ if [ -f ../in-progress ]; then
139139
echo "Error: A backup of $GHE_HOSTNAME may still be running on PID $pid." 1>&2
140140
echo 1>&2
141141
echo " If PID $pid is not a process related to the backup utilities, please remove" 1>&2
142-
echo " the \"$GHE_DATA_DIR/in-progress\" file and try again." 1>&2
142+
echo " the $GHE_DATA_DIR/in-progress file and try again." 1>&2
143143
exit 1
144144
fi
145145
fi
146146

147147
echo "$GHE_SNAPSHOT_TIMESTAMP $$" > ../in-progress
148+
echo "$GHE_SNAPSHOT_TIMESTAMP $$" > ${GHE_DATA_DIR}/in-progress-backup
148149

149150
echo "Starting backup of $GHE_HOSTNAME with backup-utils v$BACKUP_UTILS_VERSION in snapshot $GHE_SNAPSHOT_TIMESTAMP"
150151

@@ -279,3 +280,6 @@ ghe-detect-leaked-ssh-keys -s "$GHE_SNAPSHOT_DIR" || true
279280

280281
# Make sure we exit zero after the conditional
281282
true
283+
284+
# Remove in-progress file
285+
ghe_backup_finished

bin/ghe-restore

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,8 @@ cleanup_cluster_nodes() {
154154
# Check to make sure moreutils parallel is installed and working properly
155155
ghe_parallel_check
156156

157-
# ghe_restore_check
157+
# Check to make sure another restore process is not running
158+
ghe_restore_check
158159

159160
# Grab the host arg
160161
GHE_HOSTNAME="${GHE_RESTORE_HOST_OPT:-$GHE_RESTORE_HOST}"
@@ -174,6 +175,7 @@ GHE_RESTORE_SNAPSHOT_PATH="$(ghe-restore-snapshot-path "$snapshot_id")"
174175
GHE_RESTORE_SNAPSHOT=$(basename "$GHE_RESTORE_SNAPSHOT_PATH")
175176
export GHE_RESTORE_SNAPSHOT
176177

178+
# Check to make sure backup is not running
177179
ghe_backup_check
178180

179181
# Detect if the backup we are restoring has a leaked ssh key
@@ -587,7 +589,7 @@ echo 'End time:' $END_TIME
587589
echo 'Runtime:' $(($END_TIME - $START_TIME)) 'seconds'
588590

589591
echo "Restore of $GHE_HOSTNAME from snapshot $GHE_RESTORE_SNAPSHOT finished."
590-
rm -f ${GHE_DATA_DIR}/in-progress-restore
592+
ghe_restore_finished
591593

592594
if ! $instance_configured; then
593595
echo "To complete the restore process, please visit https://$hostname/setup/settings to review and save the appliance configuration."

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

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ ghe_restore_check() {
7575
if [ -h $GHE_RESTORE_IN_PROGRESS ]; then
7676
echo " Error: detected a restore already in progress from a previous version of ghe-restore." 1>&2
7777
echo " If there is no restore in progress anymore, please remove" 1>&2
78-
echo " the \"$GHE_RESTORE_IN_PROGRESS\" file and try again." 1>&2
78+
echo " the $GHE_RESTORE_IN_PROGRESS file and try again." 1>&2
7979
exit 1
8080
fi
8181

@@ -85,7 +85,7 @@ ghe_restore_check() {
8585
pid=$(echo "$progress" | cut -d ' ' -f 2)
8686
echo " Error: A restore of $GHE_HOSTNAME may still be running on PID $pid." 1>&2
8787
echo " If PID $pid is not a process related to the restore utilities, please remove" 1>&2
88-
echo " the \"$GHE_RESTORE_IN_PROGRESS\" file and try again." 1>&2
88+
echo " the $GHE_RESTORE_IN_PROGRESS file and try again." 1>&2
8989
exit 1
9090
fi
9191
}
@@ -94,7 +94,7 @@ ghe_backup_check() {
9494
if [ -h $GHE_BACKUP_IN_PROGRESS ]; then
9595
echo " Error: detected a backup already in progress from a previous version of ghe-backup." 1>&2
9696
echo " If there is no backup in progress anymore, please remove" 1>&2
97-
echo " the \"$GHE_DATA_DIR/i$GHE_BACKUP_IN_PROGRESS\" file and try again." 1>&2
97+
echo " the $GHE_DATA_DIR/$GHE_BACKUP_IN_PROGRESS file and try again." 1>&2
9898
exit 1
9999
fi
100100

@@ -104,23 +104,21 @@ ghe_backup_check() {
104104
pid=$(echo "$progress" | cut -d ' ' -f 2)
105105
echo " Error: A backup of $GHE_HOSTNAME may still be running on PID $pid." 1>&2
106106
echo " If PID $pid is not a process related to the backup utilities, please remove" 1>&2
107-
echo " the \"$GHE_BACKUP_IN_PROGRESS\" file and try again." 1>&2
107+
echo " the $GHE_BACKUP_IN_PROGRESS file and try again." 1>&2
108108
exit 1
109109
fi
110110
}
111111

112112
ghe_restore_finished() {
113-
echo "$GHE_RESTORE_IN_PROGRESS"
114-
if [ -f $GHE_RESTORE_IN_PROGRESS ]; then
115-
echo "$GHE_RESTORE_IN_PROGRESS exists!" 1>&2
116-
rm -f $GHE_RESTORE_IN_PROGRESS
117-
fi
113+
if [ -f $GHE_RESTORE_IN_PROGRESS ]; then
114+
rm -f $GHE_RESTORE_IN_PROGRESS
115+
fi
118116
}
119117

120118
ghe_backup_finished() {
121-
if [ -f $GHE_BACKUP_IN_PROGRESS ]; then
122-
rm -f $GHE_BACKUP_IN_PROGRESS
123-
fi
119+
if [ -f $GHE_BACKUP_IN_PROGRESS ]; then
120+
rm -f $GHE_BACKUP_IN_PROGRESS
121+
fi
124122
}
125123

126124
ghe_parallel_check() {

0 commit comments

Comments
 (0)