X-Git-Url: http://git.treefish.org/~alex/backmeupscotty.git/blobdiff_plain/1e430b756d9a96193c5a78fbf18b0ec05094307b..2da8ed681614289264c6069c03921b418b77b0ef:/backmeupscotty?ds=inline diff --git a/backmeupscotty b/backmeupscotty index efd283f..65e4d53 100644 --- a/backmeupscotty +++ b/backmeupscotty @@ -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