Skip to content
Snippets Groups Projects
Commit 6937842e authored by Jérôme Charaoui's avatar Jérôme Charaoui
Browse files

backup halt should trigger email report if enabled

parent f8755d63
No related branches found
No related tags found
No related merge requests found
...@@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ...@@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- [build] make build reproducible regardless of usrmerge (DEBBUG-915222) - [build] make build reproducible regardless of usrmerge (DEBBUG-915222)
- [core] silence exit code message unless --debug is used - [core] silence exit code message unless --debug is used
- [core] backup halt should trigger email report if enabled
## [1.2.0] - 2021-01-21 ## [1.2.0] - 2021-01-21
......
...@@ -606,6 +606,7 @@ if [ $actions_run == 0 ]; then doit=0 ...@@ -606,6 +606,7 @@ if [ $actions_run == 0 ]; then doit=0
elif [ "$reportemail" == "" ]; then doit=0 elif [ "$reportemail" == "" ]; then doit=0
elif [ $fatals != 0 ]; then doit=1 elif [ $fatals != 0 ]; then doit=1
elif [ $errors != 0 ]; then doit=1 elif [ $errors != 0 ]; then doit=1
elif [ $halts != 0 ]; then doit=1
elif [ "$reportsuccess" == "yes" ]; then doit=1 elif [ "$reportsuccess" == "yes" ]; then doit=1
elif [ "$reportwarning" == "yes" -a $warnings != 0 ]; then doit=1 elif [ "$reportwarning" == "yes" -a $warnings != 0 ]; then doit=1
else doit=0 else doit=0
...@@ -617,6 +618,7 @@ if [ $doit == 1 ]; then ...@@ -617,6 +618,7 @@ if [ $doit == 1 ]; then
[ $warnings == 0 ] || subject="WARNING" [ $warnings == 0 ] || subject="WARNING"
[ $errors == 0 ] || subject="ERROR" [ $errors == 0 ] || subject="ERROR"
[ $fatals == 0 ] || subject="FAILED" [ $fatals == 0 ] || subject="FAILED"
[ $halts == 0 ] || subject="HALTED"
{ {
for ((i=0; i < ${#messages[@]} ; i++)); do for ((i=0; i < ${#messages[@]} ; i++)); do
......
...@@ -68,14 +68,21 @@ create_test_action() { ...@@ -68,14 +68,21 @@ create_test_action() {
echo "${lines[0]}" | grep -qe '^Configuration files must not be writable/readable by group staff!' echo "${lines[0]}" | grep -qe '^Configuration files must not be writable/readable by group staff!'
} }
@test "reports: error report is mailed" { @test "reports: report is mailed when halts > 0" {
create_test_action halt test_halt
run backupninja --now -f "${BATS_TMPDIR}/backupninja.conf" --run "${BATS_TMPDIR}/backup.d/test.sh"
sleep 0.1
grep -q "\*halt\* -- ${BATS_TMPDIR}/backup.d/test.sh" /var/mail/vagrant
}
@test "reports: report is mailed when fatals > 0" {
create_test_action fatal test_error create_test_action fatal test_error
run backupninja --now -f "${BATS_TMPDIR}/backupninja.conf" --run "${BATS_TMPDIR}/backup.d/test.sh" run backupninja --now -f "${BATS_TMPDIR}/backupninja.conf" --run "${BATS_TMPDIR}/backup.d/test.sh"
sleep 0.1 sleep 0.1
grep -q "\*failed\* -- ${BATS_TMPDIR}/backup.d/test.sh" /var/mail/vagrant grep -q "\*failed\* -- ${BATS_TMPDIR}/backup.d/test.sh" /var/mail/vagrant
} }
@test "reports: warning report is mailed" { @test "reports: report is mailed when reportwarning = yes and warnings > 0" {
create_test_action warning test_warning create_test_action warning test_warning
setconfig backupninja.conf reportsuccess no setconfig backupninja.conf reportsuccess no
setconfig backupninja.conf reportwarning yes setconfig backupninja.conf reportwarning yes
...@@ -84,7 +91,7 @@ create_test_action() { ...@@ -84,7 +91,7 @@ create_test_action() {
grep -q "Warning: test_warning" /var/mail/vagrant grep -q "Warning: test_warning" /var/mail/vagrant
} }
@test "reports: success report is mailed" { @test "reports: report is mailed when reportsuccess = yes" {
create_test_action create_test_action
setconfig backupninja.conf reportsuccess yes setconfig backupninja.conf reportsuccess yes
run backupninja --now -f "${BATS_TMPDIR}/backupninja.conf" --run "${BATS_TMPDIR}/backup.d/test.sh" run backupninja --now -f "${BATS_TMPDIR}/backupninja.conf" --run "${BATS_TMPDIR}/backup.d/test.sh"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment