Autogenerate lockfiles based on BORG_REPO

dev
hk 2017-06-07 10:56:51 +02:00
parent c6c34e3bcc
commit fe2cda0598
2 changed files with 7 additions and 5 deletions

View File

@ -171,8 +171,8 @@ exit_clean () {
# Default parameters
CONFIG="/etc/borgwrapper/config.sh"
LOCKFILE="/var/lock/borgwrapper.lock"
BORG="/usr/bin/borg"
LOCKDIR="/run/lock/borgwrapper"
PRE_BACKUP_CMD=()
POST_BACKUP_CMD=()
POST_VERIFY_CMD=()
@ -198,6 +198,9 @@ echo "Loading config from ${CONFIG}"
source "${CONFIG}" || exit 1
export BORG_PASSPHRASE
LOCKFILE="${LOCKDIR}/$(echo -n "${BORG_REPO}" | md5sum | cut -d ' ' -f 1).lock"
mkdir -p "${LOCKDIR}"
(
# Ensure this is the only instance running
flock -n 9 || lock_failed
@ -237,4 +240,4 @@ export BORG_PASSPHRASE
fi
exit_clean 0
) 9>${LOCKFILE}
) 9>"${LOCKFILE}"

View File

@ -27,9 +27,8 @@ KEEP_YEARLY=5
# You can use K, M, G or T binary prefixes (power of 1024), e.g., 5M = 5MiB/s = 5242880 bytes/s.
#BWLIMIT=0
# Change this if you need to have multiple borgwrapper instances running
# using different configs.
#LOCKFILE="/var/lock/borgwrapper.lock"
# Location of borgwrapper lock files
#LOCKDIR="/run/lock/borgwrapper"
# Command to execute before backup, e.g., taking a ZFS snapshot. Must return successfully
# for backup to start. POST_BACKUP_CMD is executed even if this fails.