From 1e430b756d9a96193c5a78fbf18b0ec05094307b Mon Sep 17 00:00:00 2001 From: Alexander Schmidt Date: Thu, 1 Oct 2020 10:11:14 +0200 Subject: [PATCH] adding force flag --- backmeupscotty | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/backmeupscotty b/backmeupscotty index e1fe9a5..efd283f 100644 --- a/backmeupscotty +++ b/backmeupscotty @@ -6,6 +6,7 @@ ARCHIVE_KEEPNBACKUPS=30 ARCHIVE_KEEPNDAYS=30 BACKUP_RUNEVERYNTHDAY=1 BWLIMIT=500KiB +BACKUP_FORCE=0 _ERROR_ENCOUNTERED=0 @@ -183,12 +184,13 @@ Usage: $(basename $0) [OPTION]... Recognized options: -q Only output errors -n Run only on nth day + -f Force backup -h Print out this help EOF } function backmeupscotty { - while getopts "qn:h" opt; do + while getopts "qn:fh" opt; do case $opt in q) exec > /dev/null @@ -196,6 +198,9 @@ function backmeupscotty { n) BACKUP_RUNEVERYNTHDAY=$OPTARG ;; + f) + BACKUP_FORCE=1 + ;; h) printhelp exit 0 @@ -205,7 +210,9 @@ function backmeupscotty { ssh255 $REMOTE_HOST exit - if latestTooOld; then + 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." -- 2.39.5