diff options
-rwxr-xr-x | borger | 3 |
1 files changed, 3 insertions, 0 deletions
@@ -30,6 +30,7 @@ OPTION="$2" BASE_CONFIG="$HOME/.config/borger" CONFIG="$BASE_CONFIG/$DESTINATION" INTERVAL="2h" +TMP="${TMP:-/tmp}" # Print info function info { @@ -198,6 +199,7 @@ function borger_prune { function borger_set_lockfile { if [ ! -z "$LOCKFILE" ]; then mkdir -p `dirname $LOCKFILE` + if ( set -o noclobber; echo "$$" > "$LOCKFILE" ) &> /dev/null; then trap 'borger_unset_lockfile' INT TERM EXIT else @@ -220,6 +222,7 @@ function borger_check_lockfile { if [ ! -z "$LOCKFILE" ] && [ -f "$LOCKFILE" ]; then pid="`cat $LOCKFILE`" process="`ps --no-headers -o comm $pid`" + if [ "$?" == "0" ] && [ "`ps --no-headers -o comm $$`" == "$process" ]; then fatal "Another program is running for $LOCKFILE, skipping run" else |