diff --git a/transfer.sh b/transfer.sh index 463c28d6237466c6cdc089025f6e7246b629f07b..cd4fdf0f635ffbc369d99436462f0f6ef31e271f 100755 --- a/transfer.sh +++ b/transfer.sh @@ -29,6 +29,7 @@ # 2021-01-29 ah,ds, v1.12 abort on empty passphrase # 2021-05-19 ah,ds, v2.0 plugin driven to support multiple backup tools (duplicity + restic) # 2021-12-02 ah v2.1 added parameter "prune" to cleanup only +# 2022-02-10 ah v2.2 update logging (removing tee) # ================================================================================ @@ -130,14 +131,16 @@ if [ "$1" = "prune" ]; then doBackup=0 fi + exec 1> >( tee -a "$transferlog" ) 2>&1 + echo "INFO: Start logging into $transferlog" - h1 `date` TRANSFER LOCAL DATA TO STORAGE | tee -a $transferlog + h1 `date` TRANSFER LOCAL DATA TO STORAGE - echo "METHOD : $METHOD" | tee -a $transferlog - echo "TARGET : ${STORAGE_BASEDIR}" | tee -a $transferlog - echo "REGISTER : ${STORAGE_REGISTER}" | tee -a $transferlog - echo "TOOL : $STORAGE_BIN" | tee -a $transferlog - echo | tee -a $transferlog + echo "METHOD : $METHOD" + echo "TARGET : ${STORAGE_BASEDIR}" + echo "REGISTER : ${STORAGE_REGISTER}" + echo "TOOL : $STORAGE_BIN" + echo . `dirname $0`/plugins/transfer/$STORAGE_BIN.sh || exit 1 test -z "$STORAGE_REGISTER" || . `dirname $0`/plugins/register/$STORAGE_REGISTER.sh || exit 1 @@ -242,7 +245,7 @@ sleep $iRnd fi done - fi | tee -a $transferlog + fi h2 "`date` PRE transfer tasks" @@ -345,7 +348,7 @@ echo $rc > ${rcfile} exit $rc - ) | tee -a $transferlog + ) # rc=${PIPESTATUS[0]} rc=`cat ${rcfile}` @@ -364,22 +367,22 @@ echo "SKIP" else unregisterBackupSlot `hostname -f` $rc - fi | tee -a $transferlog + fi h2 "`date` Backup finished" - echo STATUS $0 exit with final returncode rc=$rc | tee -a $transferlog - echo | tee -a $transferlog + echo STATUS $0 exit with final returncode rc=$rc + echo if [ $rc -eq 0 ]; then color ok - echo Backup OK | tee -a $transferlog + echo Backup OK else color error - echo Backup FAILED :-/ | tee -a $transferlog + echo Backup FAILED :-/ fi color reset - echo | tee -a $transferlog + echo typeset -i TIMER_TRANSFER=`date +%s`-$TIMER_TRANSFER_START - echo `date` TRANSFER DONE in $TIMER_TRANSFER sec | tee -a $transferlog + echo `date` TRANSFER DONE in $TIMER_TRANSFER sec ls -l $transferlog exit $rc