]> git.treefish.org Git - backmeupscotty.git/blobdiff - backmeupscotty
Exit if another instance is already running
[backmeupscotty.git] / backmeupscotty
index 1b7fa19a1cd7c89b59afedef64b4237e5e533806..0af4cd5927c371d515f45d36c9241945e6d2bbfd 100644 (file)
@@ -5,6 +5,11 @@ REMOTE_BASE=/tmp/backmeupscotty
 ARCHIVE_KEEPNBACKUPS=30
 ARCHIVE_KEEPNDAYS=30
 
+if [ $(pidof -x $(basename $0) | wc -w) -gt 2 ]; then 
+    echo BACKMEUPSCOTTY: Another instance of $(basename $0) is already running! >&2
+    exit 1
+fi
+
 while getopts ":q" opt; do
     case $opt in
        q)
@@ -37,6 +42,10 @@ function scottysync {
        ssh $REMOTE_HOST "mkdir $REMOTE_BASE/$2"
     fi
 
+    if (ssh $REMOTE_HOST '[ -d '$REMOTE_BASE/$2/incomplete' ]'); then
+       echo BACKMEUPSCOTTY: Continuing old incomplete backup >&2
+    fi
+
     echo BACKMEUPSCOTTY: Starting rsync
     rsync -e ssh \
        -v -aHAX --numeric-ids --delete --delete-excluded \