Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Notifications do not get sent on locking failure #412

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions cmd/backup/run_script.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ func runScript(c *Config) (err error) {

s := newScript(c)

if initErr := s.initNotifications(); initErr != nil {
err = errwrap.Wrap(initErr, "error initializing notifications")
return
}

unlock, lockErr := s.lock("/var/lock/dockervolumebackup.lock")
if lockErr != nil {
err = errwrap.Wrap(lockErr, "error acquiring file lock")
Expand Down
6 changes: 5 additions & 1 deletion cmd/backup/script.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,10 @@ func (s *script) init() error {
s.storages = append(s.storages, dropboxBackend)
}

return nil
}

func (s *script) initNotifications() error {
if s.c.EmailNotificationRecipient != "" {
emailURL := fmt.Sprintf(
"smtp://%s:%s@%s:%d/?from=%s&to=%s",
Expand Down Expand Up @@ -253,6 +257,7 @@ func (s *script) init() error {

tmpl := template.New("")
tmpl.Funcs(templateHelpers)
var err error
tmpl, err = tmpl.Parse(defaultNotifications)
if err != nil {
return errwrap.Wrap(err, "unable to parse default notifications templates")
Expand Down Expand Up @@ -281,6 +286,5 @@ func (s *script) init() error {
return s.notifySuccess()
})
}

return nil
}
Loading