]> git.treefish.org Git - backmeupscotty.git/blobdiff - backmeupscotty
Do not lock exclusively when listing backups
[backmeupscotty.git] / backmeupscotty
index e1fe9a54d2387bd72c79fa398251056e43c6b4cd..65e4d53310b732200dc2c67edcd941f7caaf2b31 100644 (file)
@@ -6,6 +6,7 @@ ARCHIVE_KEEPNBACKUPS=30
 ARCHIVE_KEEPNDAYS=30
 BACKUP_RUNEVERYNTHDAY=1
 BWLIMIT=500KiB
 ARCHIVE_KEEPNDAYS=30
 BACKUP_RUNEVERYNTHDAY=1
 BWLIMIT=500KiB
+BACKUP_FORCE=0
 
 _ERROR_ENCOUNTERED=0
 
 
 _ERROR_ENCOUNTERED=0
 
@@ -183,12 +184,23 @@ Usage: $(basename $0) [OPTION]...
 Recognized options:
   -q   Only output errors
   -n   Run only on nth day
 Recognized options:
   -q   Only output errors
   -n   Run only on nth day
+  -f   Force backup
+  -l   List existing backups
   -h   Print out this help
 EOF
 }
 
   -h   Print out this help
 EOF
 }
 
+function exclusiveLock {
+    if ! mkdir /var/lock/$(basename $0); then
+       scottyerror "Another instance of $(basename $0) is still running!"
+       exit 1
+    else
+       trap deleteLock EXIT
+    fi
+}
+
 function backmeupscotty {
 function backmeupscotty {
-    while getopts "qn:h" opt; do
+    while getopts "qn:flh" opt; do
         case $opt in
             q)
                 exec > /dev/null
         case $opt in
             q)
                 exec > /dev/null
@@ -196,6 +208,12 @@ function backmeupscotty {
             n)
                 BACKUP_RUNEVERYNTHDAY=$OPTARG
                 ;;
             n)
                 BACKUP_RUNEVERYNTHDAY=$OPTARG
                 ;;
+            f)
+                BACKUP_FORCE=1
+                ;;
+           l)
+               LIST_BACKUPS=1
+               ;;
             h)
                 printhelp
                 exit 0
             h)
                 printhelp
                 exit 0
@@ -205,7 +223,18 @@ function backmeupscotty {
 
     ssh255 $REMOTE_HOST exit
 
 
     ssh255 $REMOTE_HOST exit
 
-    if latestTooOld; then
+    if [ $LIST_BACKUPS ]; then
+       for backup in $(grepbackups); do
+           echo $backup
+       done
+       exit 0
+    fi
+
+    exclusiveLock
+
+    if [ $BACKUP_FORCE -eq 1 ]; then
+        scottyinfo "Backup was enforced."
+    elif latestTooOld; then
         scottyerror "The latest backup is too old."
     elif isNthDay; then
         scottyinfo "This is the nth day."
         scottyerror "The latest backup is too old."
     elif isNthDay; then
         scottyinfo "This is the nth day."
@@ -225,10 +254,3 @@ function backmeupscotty {
 
     exit 0
 }
 
     exit 0
 }
-
-if ! mkdir /var/lock/$(basename $0); then
-    scottyerror "Another instance of $(basename $0) is still running!"
-    exit 1
-else
-    trap deleteLock EXIT
-fi