]> git.treefish.org Git - backmeupscotty.git/blobdiff - backmeupscotty
Repaired nth day option.
[backmeupscotty.git] / backmeupscotty
index c1fa9da8387aea23f276e1092c8abf31c9fd191c..efda418d28119de54b1f9fc4617192c8ce8dd34c 100644 (file)
@@ -141,10 +141,20 @@ function cleanup_normal {
 
 function _cleanup_normal {
     cleanup_normal
-    deleteLock
 }
 
 function backmeupscotty {
+    while getopts "qn:" opt; do
+       case $opt in
+           q)
+               exec > /dev/null
+               ;;
+           n)
+               BACKUP_RUNEVERYNTHDAY=$OPTARG
+               ;;
+       esac
+    done
+
     if ! isIncompleteOrNthDay; then
        scottyinfo "This is not the nth day and no incomplete backup exists."
        exit 0
@@ -156,21 +166,12 @@ function backmeupscotty {
     scottysync
     _cleanup_normal
 
-    trap - EXIT
+    trap deleteLock EXIT
 }
 
 if ! mkdir /tmp/$(basename $0).lock; then
     scottyerror "Another instance of $(basename $0) is still running!"
     exit 1
+else
+    trap deleteLock EXIT
 fi
-
-while getopts "qn:" opt; do
-    case $opt in
-       q)
-           exec > /dev/null
-           ;;
-       n)
-           BACKUP_RUNEVERYNTHDAY=$OPTARG
-           ;;
-    esac
-done