]> git.treefish.org Git - backmeupscotty.git/blobdiff - backmeupscotty
Do not lock exclusively when listing backups
[backmeupscotty.git] / backmeupscotty
index efd283f6cc772225c35e9344a2a669adccc567c6..65e4d53310b732200dc2c67edcd941f7caaf2b31 100644 (file)
@@ -185,12 +185,22 @@ 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
 }
 
+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 {
-    while getopts "qn:fh" opt; do
+    while getopts "qn:flh" opt; do
         case $opt in
             q)
                 exec > /dev/null
@@ -201,6 +211,9 @@ function backmeupscotty {
             f)
                 BACKUP_FORCE=1
                 ;;
+           l)
+               LIST_BACKUPS=1
+               ;;
             h)
                 printhelp
                 exit 0
@@ -210,6 +223,15 @@ function backmeupscotty {
 
     ssh255 $REMOTE_HOST exit
 
+    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
@@ -232,10 +254,3 @@ function backmeupscotty {
 
     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