Our backupscript for automated server backups via cronjob
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
688 B

#!/bin/bash
LOCKDIR="/tmp/snapshotslocks/"
[ ! -d "$LOCKDIR" ] && mkdir -p "$LOCKDIR"
createlock() {
LOCKNAME=$1
[ -f "$LOCKDIR/$LOCKNAME.lock" ] && exit 1
touch "$LOCKDIR/$LOCKNAME.lock"
exit 0
}
deletelock() {
LOCKNAME=$1
[ ! -f "$LOCKDIR/$LOCKNAME.lock" ] && exit 1
rm "$LOCKDIR/$LOCKNAME.lock"
exit 0
}
haslock() {
if ls $LOCKDIR/* 1> /dev/null 2>&1; then
exit 0
else
exit 1
fi
}
case $1 in
lock)
createlock $2
;;
unlock)
deletelock $2
;;
haslock)
haslock
;;
show)
ls $LOCKDIR
;;
*)
echo "What is $1" >&2
exit 1
esac