Current location

narf Source control manager Git

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier Mehani <shtrom@ssji.net>2022-09-27 14:52:51 +0200
committerOlivier Mehani <shtrom@ssji.net>2022-09-27 14:52:51 +0200
commit1fe5ceecf5f7dadd9cd1e95bd8328ef8fc9c4e0c (patch)
treeec97a7cac9d1afdc0e0319f1b0fb55ba33b11c40
parent9de69814d7c3f96ee03597945c18856bbcc31ac1 (diff)
[openbsd] backup.sh: add PID handlingHEADmaster
Signed-off-by: Olivier Mehani <shtrom@ssji.net>
-rwxr-xr-xopenbsd/backup.sh13
1 files changed, 13 insertions, 0 deletions
diff --git a/openbsd/backup.sh b/openbsd/backup.sh
index 9810d54..2313f68 100755
--- a/openbsd/backup.sh
+++ b/openbsd/backup.sh
@@ -2,6 +2,7 @@
# The following variables can be overridden in /etc/backup.sh.conf
DIRS="/etc /srv"
TMPSUBDIR=/tmp
+PID=/var/run/backup.pid
BACKUPROOT="/srv/rdiff-backup"
BACKUPDIR="${BACKUPROOT}/`hostname -s`"
@@ -25,6 +26,16 @@ LDAPPASS="secret"
test -e /etc/backup.sh.conf && . /etc/backup.sh.conf
+if [ -e "${PID}" ]; then
+ if kill -0 $(cat ${PID}); then
+ echo "Previous instance of ${0} still running as $(cat ${PID}), exiting..."
+ exit 0
+ else
+ echo "Found stale ${PID}, taking over..."
+ fi
+fi
+echo $$ > ${PID}
+
# Dump privilege information [0]
# [0] http://serverfault.com/questions/8860/how-can-i-export-the-privileges-from-mysql-and-then-import-to-a-new-server/13050#13050
mysqldump-grants()
@@ -96,3 +107,5 @@ if [ -n "${BACKUPHORIZON}" ]; then
done
echo "."
fi
+
+rm ${PID}