From 2da8ed681614289264c6069c03921b418b77b0ef Mon Sep 17 00:00:00 2001 From: Alexander Schmidt Date: Tue, 26 Sep 2023 23:11:01 +0200 Subject: [PATCH] Do not lock exclusively when listing backups --- backmeupscotty | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/backmeupscotty b/backmeupscotty index 579b63a..65e4d53 100644 --- a/backmeupscotty +++ b/backmeupscotty @@ -190,6 +190,15 @@ Recognized options: EOF } +function exclusiveLock { + if ! mkdir /var/lock/$(basename $0); then + scottyerror "Another instance of $(basename $0) is still running!" + exit 1 + else + trap deleteLock EXIT + fi +} + function backmeupscotty { while getopts "qn:flh" opt; do case $opt in @@ -221,6 +230,8 @@ function backmeupscotty { exit 0 fi + exclusiveLock + if [ $BACKUP_FORCE -eq 1 ]; then scottyinfo "Backup was enforced." elif latestTooOld; then @@ -243,10 +254,3 @@ function backmeupscotty { exit 0 } - -if ! mkdir /var/lock/$(basename $0); then - scottyerror "Another instance of $(basename $0) is still running!" - exit 1 -else - trap deleteLock EXIT -fi -- 2.39.5