diff --git a/transfer.sh b/transfer.sh index a8c9ad0e6b74ec86cf59bcdeb83c1ed46cee4e76..dd0c900a3884bfcb84d01839153ea468a4c2874a 100755 --- a/transfer.sh +++ b/transfer.sh @@ -141,6 +141,7 @@ function _getFileAge(){ function setAction(){ local action=$1 local myfile=$2 + local doforce=$3 local iLimit iLimit=$(_j_getvar ${STORAGEFILE} "${action}-after") @@ -154,16 +155,21 @@ function setAction(){ echo "Info: $action is ENABLED - no last $action detected" doValue=1 else - typeset -i iLastDone - iLastDone=$( _getFileAge "${myfile}" )/60 - typeset -i iLastDoneD=iLastDone/60/24 - echo "Info: Last $action was $iLastDone min ago ($iLastDoneD days). Limit is $iLimit days." - if [ $iLastDoneD -ge $iLimit ]; then - echo "Info: $action is ENABLED - last $action is outdated" + if [ "$doforce" -eq "1" ]; then + echo "Force $action" doValue=1 else - echo "Info: $action is not needed yet." - doValue=0 + typeset -i iLastDone + iLastDone=$( _getFileAge "${myfile}" )/60 + typeset -i iLastDoneD=iLastDone/60/24 + echo "Info: Last $action was $iLastDone min ago ($iLastDoneD days). Limit is $iLimit days." + if [ $iLastDoneD -ge $iLimit ]; then + echo "Info: $action is ENABLED - last $action is outdated" + doValue=1 + else + echo "Info: $action is not needed yet." + doValue=0 + fi fi fi } @@ -193,8 +199,8 @@ function setAction(){ # set defaults for prune and verify echo ">>> Detect default behaviour:" - setAction "prune" "$lastprunefile"; doPrune=$doValue - setAction "verify" "$lastverifyfile"; doVerify=$doValue + setAction "prune" "$lastprunefile" 0; doPrune=$doValue + setAction "verify" "$lastverifyfile" 0; doVerify=$doValue echo echo ">>> Check parameters" @@ -202,7 +208,7 @@ function setAction(){ echo "Info: Forcing prune only by parameter." ACTION=$1 doBackup=0 - doPrune=1 + setAction "prune" "$lastprunefile" 1; doPrune=$doValue doVerify=0 transferlog="${DIR_LOGS}/prune-$(date +%Y%m%d-%H%M%S).log" fi @@ -214,6 +220,12 @@ function setAction(){ doVerify=1 transferlog="${DIR_LOGS}/verify-$(date +%Y%m%d-%H%M%S).log" fi + + if [ "${doBackup}${doPrune}${doVerify}" = "000" ]; then + echo "Nothing to do. Aborting." + exit 0 + fi + exec 1> >( tee -a "$transferlog" ) 2>&1 echo "INFO: Start logging into $transferlog"