@@ -66,6 +66,67 @@ for f in "$GHE_BACKUP_CONFIG" "$GHE_BACKUP_ROOT/backup.config" \
66
66
fi
67
67
done
68
68
69
+ GHE_RESTORE_IN_PROGRESS=" ${GHE_DATA_DIR} /.in-progress-restore"
70
+ GHE_BACKUP_IN_PROGRESS=" ${GHE_DATA_DIR} /.in-progress"
71
+ export GHE_RESTORE_IN_PROGRESS
72
+ export GHE_BACKUP_IN_PROGRESS
73
+
74
+ ghe_restore_started () {
75
+ echo " $1 $$ " > $GHE_RESTORE_IN_PROGRESS
76
+ }
77
+
78
+ ghe_restore_check () {
79
+ if [ -h $GHE_RESTORE_IN_PROGRESS ]; then
80
+ echo " Error: detected a restore already in progress from a previous version of ghe-restore." 1>&2
81
+ echo " If there is no restore in progress anymore, please remove" 1>&2
82
+ echo " the $GHE_DATA_DIR /in-progress-restore file." 1>&2
83
+ exit 1
84
+ fi
85
+
86
+ if [ -f $GHE_RESTORE_IN_PROGRESS ]; then
87
+ progress=$( cat $GHE_RESTORE_IN_PROGRESS )
88
+ snapshot=$( echo " $progress " | cut -d ' ' -f 1)
89
+ pid=$( echo " $progress " | cut -d ' ' -f 2)
90
+ echo " Error: A restore of $GHE_HOSTNAME may still be running on PID $pid ." 1>&2
91
+ echo " If PID $pid is not a process related to the restore utilities, please remove" 1>&2
92
+ echo " the $GHE_DATA_DIR /in-progress-restore file and try again." 1>&2
93
+ exit 1
94
+ fi
95
+ }
96
+
97
+ ghe_backup_check () {
98
+ if [ -h $GHE_BACKUP_IN_PROGRESS ]; then
99
+ echo " Error: detected a backup already in progress from a previous version of ghe-backup." 1>&2
100
+ echo " If there is no backup in progress anymore, please remove" 1>&2
101
+ echo " the $GHE_DATA_DIR /in-progress-backup file." 1>&2
102
+ exit 1
103
+ fi
104
+
105
+ if [ -f $GHE_BACKUP_IN_PROGRESS ]; then
106
+ progress=$( cat $GHE_BACKUP_IN_PROGRESS )
107
+ snapshot=$( echo " $progress " | cut -d ' ' -f 1)
108
+ pid=$( echo " $progress " | cut -d ' ' -f 2)
109
+ echo " Error: A backup of $GHE_HOSTNAME may still be running on PID $pid ." 1>&2
110
+ echo " If PID $pid is not a process related to the backup utilities, please remove" 1>&2
111
+ echo " the $GHE_DATA_DIR /in-progress file and try again." 1>&2
112
+ exit 1
113
+ fi
114
+ }
115
+
116
+ ghe_restore_finished () {
117
+ echo " $GHE_RESTORE_IN_PROGRESS "
118
+ if [ -f $GHE_RESTORE_IN_PROGRESS ]; then
119
+ echo " $GHE_RESTORE_IN_PROGRESS exists!" 1>&2
120
+ rm -f $GHE_RESTORE_IN_PROGRESS
121
+ fi
122
+ }
123
+
124
+ ghe_backup_finished () {
125
+ if [ ! -f $GHE_BACKUP_IN_PROGRESS ]; then
126
+ rm -f $GHE_BACKUP_IN_PROGRESS
127
+ fi
128
+ }
129
+
69
130
ghe_parallel_check () {
70
131
if [ " $GHE_PARALLEL_ENABLED " != " yes" ]; then
71
132
return 0
0 commit comments