summaryrefslogtreecommitdiff
path: root/backup-run-rdiff-backup
diff options
context:
space:
mode:
authorPeter Palfrader <peter@palfrader.org>2013-01-09 10:41:11 +0000
committerweasel <weasel@bc3d92e2-beff-0310-a7cd-cc87d7ac0ede>2013-01-09 10:41:11 +0000
commitd835d9dfc5458281b227321b82ab824782226a8a (patch)
tree76e74a5f97d32a476f7a0bf45b0ea6f87261e139 /backup-run-rdiff-backup
parent147c93082d525a614fbc79746420df5ff8aa668d (diff)
Do locking inside backup-run-rdiff-backup
git-svn-id: svn+ssh://asteria.noreply.org/svn/weaselutils/trunk@571 bc3d92e2-beff-0310-a7cd-cc87d7ac0ede
Diffstat (limited to 'backup-run-rdiff-backup')
-rwxr-xr-xbackup-run-rdiff-backup14
1 files changed, 11 insertions, 3 deletions
diff --git a/backup-run-rdiff-backup b/backup-run-rdiff-backup
index c1e2fea..65a7390 100755
--- a/backup-run-rdiff-backup
+++ b/backup-run-rdiff-backup
@@ -26,8 +26,8 @@ set -e
set -u
host="$(hostname)"
-base="/Auto/net-backup/backups/"
-keep=12W
+base="/Auto/net-backup/backups"
+keep=24W
if [ "${1:-}" = "-v" ]; then
verbose="--terminal-verbosity=5"
@@ -42,7 +42,14 @@ if ! [ -d "$base" ] ; then
exit 1
fi
+hostbase="$base/$host"
+mkdir -p "$hostbase"
+exec 200< "$hostbase"
+if ! flock -w 0 -e 200; then
+ echo >&2 "Error: Cannot acquire lock."
+ exit 1
+fi
for dir in $(df -Pkl -x tmpfs -x iso9660 -x devtmpfs | tail -n +2 | awk '{print $NF}' | sort -u); do
[ -e "$dir/.nobackup" ] && continue
@@ -52,7 +59,8 @@ for dir in $(df -Pkl -x tmpfs -x iso9660 -x devtmpfs | tail -n +2 | awk '{print
else
cleaned="$(echo "$dir" | tr '/' '-')"
fi
- tgt="$base/$host-$cleaned"
+ cleaned="${cleaned#-}"
+ tgt="$hostbase/$cleaned"
if [ -e "$dir"/.rdiff-exclude ]; then
exclude="--exclude-globbing-filelist=$dir/.rdiff-exclude"