mirror of
https://0xacab.org/liberate/backupninja.git
synced 2024-11-08 11:52:32 +01:00
improve error handling around reporthost feature
This commit is contained in:
parent
f6870a613e
commit
25c3a9f421
@ -21,6 +21,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- [core] silence exit code message unless --debug is used
|
||||
- [core] backup halt should trigger email report if enabled
|
||||
- [core] wrap report email body to 1000 characters by default (DEBBUG-871793)
|
||||
- [core] improve error handling around reporthost feature
|
||||
|
||||
## [1.2.0] - 2021-01-21
|
||||
|
||||
|
@ -652,8 +652,24 @@ if [ $actions_run != 0 ]; then
|
||||
fi
|
||||
|
||||
if [ -n "$reporthost" ]; then
|
||||
debug "send $logfile to $reportuser@$reporthost:$reportdirectory"
|
||||
rsync -qt $logfile $reportuser@$reporthost:$reportdirectory
|
||||
if [ -z "$reportuser" ] || [ -z "$reportdirectory" ]; then
|
||||
error "Unable to send report, reportuser and reportdirectory must be specified."
|
||||
let "errors += 1"
|
||||
elif [ ! -x "$(which rsync 2>/dev/null)" ]; then
|
||||
error "Unable to locate rsync executable, report could not be sent to ${reporthost}."
|
||||
let "errors += 1"
|
||||
else
|
||||
info "Sending $logfile to $reportuser@$reporthost:$reportdirectory"
|
||||
execstr="rsync -qt $logfile $reportuser@$reporthost:$reportdirectory"
|
||||
debug $execstr
|
||||
output=$(eval $execstr 2>&1)
|
||||
ret=$?
|
||||
if [ $ret -ne 0 ]; then
|
||||
error $output
|
||||
error "An error was encountered attempting to send report to ${reporthost}."
|
||||
let "errors += 1"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# return exit code
|
||||
|
Loading…
Reference in New Issue
Block a user