4444# Check to make sure moreutils parallel is installed and working properly
4545ghe_parallel_check
4646
47+
4748# Used to record failed backup steps
4849failures=
4950failures_file=" $( mktemp -t backup-utils-backup-failures-XXXXXX) "
@@ -63,7 +64,7 @@ touch "incomplete"
6364# Exit early if the snapshot filesystem doesn't support hard links, symlinks and
6465# if rsync doesn't support hardlinking of dangling symlinks
6566trap ' rm -rf src dest1 dest2' EXIT
66- mkdir src
67+ mkdir -p src
6768touch src/testfile
6869if ! ln -s /data/does/not/exist/hooks/ src/ > /dev/null 2>&1 ; then
6970 echo " Error: the filesystem containing $GHE_DATA_DIR does not support symbolic links." 1>&2
@@ -105,6 +106,7 @@ cleanup () {
105106 fi
106107
107108 rm -rf " $failures_file "
109+ rm -f ${GHE_DATA_DIR} /in-progress-backup
108110
109111 # Cleanup SSH multiplexing
110112 ghe-ssh --clean
@@ -114,10 +116,15 @@ cleanup () {
114116trap ' cleanup' EXIT
115117trap ' exit $?' INT # ^C always terminate
116118
119+
120+ # Check to see if there is a running restore
121+ ghe_restore_check
122+
123+ # Check to see if there is a running backup
117124if [ -h ../in-progress ]; then
118125 echo " Error: detected a backup already in progress from a previous version of ghe-backup." 1>&2
119126 echo " If there is no backup in progress anymore, please remove" 1>&2
120- echo " the $GHE_DATA_DIR /in-progress file." 1>&2
127+ echo " the $GHE_DATA_DIR /in-progress file and try again ." 1>&2
121128 exit 1
122129fi
123130
@@ -131,13 +138,15 @@ if [ -f ../in-progress ]; then
131138 unlink ../in-progress
132139 else
133140 echo " Error: A backup of $GHE_HOSTNAME may still be running on PID $pid ." 1>&2
134- echo " If PID $pid is not a process related to the backup utilities, please remove" 1>&2
135- echo " the $GHE_DATA_DIR /in-progress file and try again." 1>&2
141+ echo 1>&2
142+ echo " If PID $pid is not a process related to the backup utilities, please remove" 1>&2
143+ echo " the $GHE_DATA_DIR /in-progress file and try again." 1>&2
136144 exit 1
137145 fi
138146fi
139147
140148echo " $GHE_SNAPSHOT_TIMESTAMP $$ " > ../in-progress
149+ echo " $GHE_SNAPSHOT_TIMESTAMP $$ " > ${GHE_DATA_DIR} /in-progress-backup
141150
142151START_TIME=$( date +%s)
143152echo ' Start time:' $START_TIME
@@ -278,3 +287,6 @@ ghe-detect-leaked-ssh-keys -s "$GHE_SNAPSHOT_DIR" || true
278287
279288# Make sure we exit zero after the conditional
280289true
290+
291+ # Remove in-progress file
292+ ghe_backup_finished
0 commit comments