Skip to content
Snippets Groups Projects
Commit 62275476 authored by Hahn Axel (hahn)'s avatar Hahn Axel (hahn)
Browse files

Merge branch '5046-finetune-restic-params' into 'master'

5046 finetune restic params

See merge request !35
parents 97c78f48 41077828
No related branches found
No related tags found
1 merge request!355046 finetune restic params
......@@ -13,6 +13,7 @@
#
# 2016-12-09 ah,ds v1.0
# 2022-01-19 ah v1.1 fixes with shellcheck
# 2022-02-09 ah v1.2 update after changes in logging
# ==============================================================================
. $(dirname $0)/jobhelper.sh
......@@ -39,7 +40,7 @@ logdir=$(dirname "$0")/logs
sShort="Client Backup -"
ls "$logdir"/*.log >/dev/null
ls "$logdir"/*.log* >/dev/null
if [ $? -ne 0 ]; then
sShort="$sShort logs were not found. Backup was never executed"
iError=1
......@@ -48,13 +49,22 @@ else
# iMaxAgeInHours=`j_getLastBackupAge`
# echo verify last backup: $iMaxAgeInHours h ago
for logfile in $(ls -1t "$logdir"/inc*.log "$logdir"/full*.log "$logdir"/auto*.log 2>/dev/null | head -1)
do
# for logfile in $(ls -1t "$logdir"/inc*.log "$logdir"/full*.log "$logdir"/auto*.log 2>/dev/null | head -1)
# do
backuplogfile=$(ls -1t "$logdir"/inc*.log "$logdir"/full*.log "$logdir"/auto*.log 2>/dev/null | head -1)
transferlogfile=$(ls -1t "$logdir"/transfer*.log | head -1)
logfile="${backuplogfile} ${transferlogfile}"
lastlogfile="$(ls -1t $logfile | head -1)"
echo LAST BACKUP: "$logfile"
grep "final.*rc=" "$logfile"
echo
echo ">>> RETURNCODES"
grep "final.*rc=" $logfile
# --- SENSU Statusline
# --- Monitoring Statusline
if [ -f "$(dirname $0)"/transfer.sh ]; then
sShort="$sShort WITH"
else
......@@ -63,47 +73,50 @@ else
sShort="$sShort transfer -"
# --- count returncodes
iOK=$(grep -c "final.*rc=0$" "$logfile" )
iError=$(grep "final.*rc=" "$logfile" | grep -cv "rc=0$")
iOK=$(grep "final.*rc=0$" $logfile | wc -l )
iError=$(grep "final.*rc=" $logfile | grep -v "rc=0$" | wc -l )
echo "OK: $iOK ... Errors: $iError"
# --- rc=0 must be here
if [ $iOK -eq 0 ]; then
echo "ERROR: no OK message was found. Something is messed up :-/"
iError=$iError+1
iError+=1
fi
# --- check age
iAge=$( date +%s )-$( date +%s -r "$logfile" )
echo
echo ">>> AGE"
iAge=$( date +%s )-$( date +%s -r "$lastlogfile" )
iAge2=$iAge/60/60
echo "age: $iAge sec ... $iAge2 h"
sShort="$sShort last backup log: $(basename "$logfile") ($iAge2 h ago) "
sShort="$sShort last backup log: $(basename "$lastlogfile") ($iAge2 h ago) "
if [ $iAge2 -gt $iMaxAgeInHours ]; then
echo "Error: the last backup is older than $iMaxAgeInHours hours"
sShort="$sShort ERROR: backup is older than $iMaxAgeInHours hours "
iError=$iError+1
iError+=1
else
echo "OK: last backup is younger $iMaxAgeInHours hours"
sShort="$sShort OK: backup is younger than $iMaxAgeInHours hours "
iOK+=1
fi
# --- changes (incremental backups only) and backup status infos
echo
sSearch="Args:|ElapsedTime|SourceFiles|SourceFileSize|RawDeltaSize"
echo "$logfile" | grep -F "inc" >/dev/null
if [ $? -eq 0 ]; then
sSearch="[ADM]\ |${sSearch}"
fi
echo --- changes:
grep -E "^(${sSearch})" "$logfile"
# echo
# sSearch="Args:|ElapsedTime|SourceFiles|SourceFileSize|RawDeltaSize"
# echo "$logfile" | grep -F "inc" >/dev/null
# if [ $? -eq 0 ]; then
# sSearch="[ADM]\ |${sSearch}"
# fi
# echo --- changes:
# grep -E "^(${sSearch})" "$logfile"
echo
echo --- summary of backed up directories:
grep "DIR\ " "$logfile"
echo ">>> Summary of backed up directories:"
cat $logfile | grep "DIR\ "
sShort="$sShort - OK: $iOK ... Errors: $iError"
done
# done
fi
......
......@@ -7,8 +7,9 @@
#
# --------------------------------------------------------------------------------
# ah - Axel Hahn <axel.hahn@iml.unibe.ch>
# 2021-05-19 ah v0.0 INIT ... WIP
# 2022-01-06 ah v0.0 added support for Repository with REST and authentication
# 2021-05-19 ah v0.1 INIT ... WIP
# 2022-01-06 ah v0.2 added support for Repository with REST and authentication
# 2022-02-09 ah v0.3 show difff to last backup; update pruning
# ================================================================================
# --------------------------------------------------------------------------------
......
......@@ -97,7 +97,7 @@
METHOD=
transferlog="${DIR_LOGS}/transfer-`date +%Y%m%d`.log"
transferlog="${DIR_LOGS}/transfer-$(date +%Y%m%d-%H%M%S).log"
lockfile="${DIR_LOGS}/transfer.running"
rcfile=/tmp/transfer-rc.$$.tmp
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment