Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
backupninja
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Liberate
backupninja
Commits
6937842e
Commit
6937842e
authored
4 years ago
by
Jérôme Charaoui
Browse files
Options
Downloads
Patches
Plain Diff
backup halt should trigger email report if enabled
parent
f8755d63
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
CHANGELOG.md
+1
-0
1 addition, 0 deletions
CHANGELOG.md
src/backupninja.in
+2
-0
2 additions, 0 deletions
src/backupninja.in
test/backupninja.bats
+10
-3
10 additions, 3 deletions
test/backupninja.bats
with
13 additions
and
3 deletions
CHANGELOG.md
+
1
−
0
View file @
6937842e
...
...
@@ -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)
-
[core] silence exit code message unless --debug is used
-
[core] backup halt should trigger email report if enabled
## [1.2.0] - 2021-01-21
...
...
This diff is collapsed.
Click to expand it.
src/backupninja.in
+
2
−
0
View file @
6937842e
...
...
@@ -606,6 +606,7 @@ if [ $actions_run == 0 ]; then doit=0
elif
[
"
$reportemail
"
==
""
]
;
then
doit
=
0
elif
[
$fatals
!=
0
]
;
then
doit
=
1
elif
[
$errors
!=
0
]
;
then
doit
=
1
elif
[
$halts
!=
0
]
;
then
doit
=
1
elif
[
"
$reportsuccess
"
==
"yes"
]
;
then
doit
=
1
elif
[
"
$reportwarning
"
==
"yes"
-a
$warnings
!=
0
]
;
then
doit
=
1
else
doit
=
0
...
...
@@ -617,6 +618,7 @@ if [ $doit == 1 ]; then
[
$warnings
==
0
]
||
subject
=
"WARNING"
[
$errors
==
0
]
||
subject
=
"ERROR"
[
$fatals
==
0
]
||
subject
=
"FAILED"
[
$halts
==
0
]
||
subject
=
"HALTED"
{
for
((
i
=
0
;
i <
${#
messages
[@]
}
;
i++
))
;
do
...
...
This diff is collapsed.
Click to expand it.
test/backupninja.bats
+
10
−
3
View file @
6937842e
...
...
@@ -68,14 +68,21 @@ create_test_action() {
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
run backupninja --now -f "${BATS_TMPDIR}/backupninja.conf" --run "${BATS_TMPDIR}/backup.d/test.sh"
sleep 0.1
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
setconfig backupninja.conf reportsuccess no
setconfig backupninja.conf reportwarning yes
...
...
@@ -84,7 +91,7 @@ create_test_action() {
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
setconfig backupninja.conf reportsuccess yes
run backupninja --now -f "${BATS_TMPDIR}/backupninja.conf" --run "${BATS_TMPDIR}/backup.d/test.sh"
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment