Skip to content

Commit 388cc51

Browse files
committed
SVCPLAN-8877: Add additional logic to return codes in case of unexpected logfile format
1 parent 64b97ff commit 388cc51

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

templates/telegraf_backup.sh.erb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,18 @@ if [ -s "$backup_run_file" ] ; then
1818
archives_pruned=$( grep -i 'Pruning archive' $backup_run_file | wc -l )
1919
backup_jobs=$( grep -i 'backup starting' $backup_run_file | wc -l )
2020
backup_return_code=$( grep -i -B1 'backup finished' $backup_run_file | grep -i terminating | grep rc | awk '{ print $NF }' | sort -rn | head -n1 )
21+
if [[ -z "$backup_return_code" ]]; then
22+
backup_return_code=1
23+
fi
2124
files_added=$( egrep '^A /' $backup_run_file | wc -l )
2225
files_changed_in_process=$( egrep '^C /' $backup_run_file | wc -l )
2326
files_errored=$( egrep '^E /' $backup_run_file | wc -l )
2427
files_modified=$( egrep '^M /' $backup_run_file | wc -l )
2528
#files_unchanged=$( egrep '^U /' $backup_run_file | wc -l )
2629
prune_return_code=$( grep -i -B1 'prune finished' $backup_run_file | grep -i terminating | grep rc | awk '{ print $NF }' | sort -rn | head -n1 )
30+
if [[ -z "$prune_return_code" ]]; then
31+
prune_return_code=1
32+
fi
2733
server_errors=$( grep -i 'No backup servers' $backup_run_file | grep -i error | wc -l)
2834
backup_run_file_timestamp_epoch_ns="${backup_run_file_timestamp_epoch}000000000"
2935

@@ -56,6 +62,9 @@ if [ -s "$backup_check_file" ] ; then
5662

5763
if [ $backup_check_file_timestamp_epoch -ge $lastrun_timestamp_epoch ] ; then
5864
return_code=$( grep -i 'terminating with' $backup_check_file | grep rc | awk '{ print $NF }' )
65+
if [[ -z "$return_code" ]]; then
66+
return_code=1
67+
fi
5968
repository_error=$( grep -i repository $backup_check_file | grep -i check | grep -i complete | grep -i found | egrep -vi ' no ' | wc -l )
6069
archive_error=$( grep -i archive $backup_check_file | grep -i check | grep -i complete | grep -i found | egrep -vi ' no ' | wc -l )
6170
chunks_missing=$( grep -i 'chunk missing' $backup_check_file | wc -l )

0 commit comments

Comments
 (0)