meskyanichi/backup — Issue #258: using global config for Mail notification config fails
Author: voxeolabs-jenkins
Created: 2012-01-15 14:30:17+00:00
State: open

If I set the mail config in the config.rb and call it from the model I get this error:

9:25:08 jdyer@aleph.local ~ backup perform -t jenkins
[2012/01/15 09:25:42][message] Performing backup for Jenkins config backups!
[2012/01/15 09:25:42][message] Backup::Archive started packaging and archiving:
[2012/01/15 09:25:42][message] /tmp
[2012/01/15 09:25:42][message] Backup::Packager started packaging the backup files.
[2012/01/15 09:25:42][message] Backup::Compressor::Gzip started compressing the archive.
[2012/01/15 09:25:42][message] Backup::Encryptor::OpenSSL started encrypting the archive.
[2012/01/15 09:25:44][message] Storage::S3 started transferring '2012.01.15.09.25.38.jenkins.tar.gz.enc' to bucket 'voxeo-labs-backups'
[2012/01/15 09:25:44][message] Backup::Notifier::Mail started notifying about the process.
[2012/01/15 09:25:44][error] ModelError: Backup for Jenkins config backups (jenkins) Failed!
[2012/01/15 09:25:44][error] An Error occured which has caused this Backup to abort before completion.
[2012/01/15 09:25:44][error] Please review the Log for this Backup to determine if steps need to be taken
[2012/01/15 09:25:44][error] to clean up, based on the point at which the failure occured.
[2012/01/15 09:25:44][error] Reason: ArgumentError
[2012/01/15 09:25:44][error] A sender (Return-Path, Sender or From) required to send a message
[2012/01/15 09:25:44][error]
[2012/01/15 09:25:44][error] Backtrace:
[2012/01/15 09:25:44][error] /Users/jdyer/.rvm/gems/ruby-1.9.3-p0@global/gems/mail-2.3.0/lib/mail/network/delivery_methods/smtp.rb:97:in `deliver!'
[2012/01/15 09:25:44][error] /Users/jdyer/.rvm/gems/ruby-1.9.3-p0@global/gems/mail-2.3.0/lib/mail/message.rb:245:in `deliver!'
[2012/01/15 09:25:44][error] /Users/jdyer/.rvm/gems/ruby-1.9.3-p0@global/gems/backup-3.0.20/lib/backup/notifier/mail.rb:142:in `notify!'
[2012/01/15 09:25:44][error] /Users/jdyer/.rvm/gems/ruby-1.9.3-p0@global/gems/backup-3.0.20/lib/backup/notifier/base.rb:66:in `perform!'
[2012/01/15 09:25:44][error] /Users/jdyer/.rvm/gems/ruby-1.9.3-p0@global/gems/backup-3.0.20/lib/backup/notifier/mail.rb:102:in `perform!'
[2012/01/15 09:25:44][error] /Users/jdyer/.rvm/gems/ruby-1.9.3-p0@global/gems/backup-3.0.20/lib/backup/model.rb:250:in `block in perform!'
[2012/01/15 09:25:44][error] /Users/jdyer/.rvm/gems/ruby-1.9.3-p0@global/gems/backup-3.0.20/lib/backup/model.rb:250:in `each'
[2012/01/15 09:25:44][error] /Users/jdyer/.rvm/gems/ruby-1.9.3-p0@global/gems/backup-3.0.20/lib/backup/model.rb:250:in `perform!'
[2012/01/15 09:25:44][error] /Users/jdyer/.rvm/gems/ruby-1.9.3-p0@global/gems/backup-3.0.20/lib/backup/cli/utility.rb:72:in `block in perform'
[2012/01/15 09:25:44][error] /Users/jdyer/.rvm/gems/ruby-1.9.3-p0@global/gems/backup-3.0.20/lib/backup/cli/utility.rb:51:in `each'
[2012/01/15 09:25:44][error] /Users/jdyer/.rvm/gems/ruby-1.9.3-p0@global/gems/backup-3.0.20/lib/backup/cli/utility.rb:51:in `perform'
[2012/01/15 09:25:44][error] /Users/jdyer/.rvm/gems/ruby-1.9.3-p0@global/gems/thor-0.14.6/lib/thor/task.rb:22:in `run'
[2012/01/15 09:25:44][error] /Users/jdyer/.rvm/gems/ruby-1.9.3-p0@global/gems/thor-0.14.6/lib/thor/invocation.rb:118:in `invoke_task'
[2012/01/15 09:25:44][error] /Users/jdyer/.rvm/gems/ruby-1.9.3-p0@global/gems/thor-0.14.6/lib/thor.rb:263:in `dispatch'
[2012/01/15 09:25:44][error] /Users/jdyer/.rvm/gems/ruby-1.9.3-p0@global/gems/thor-0.14.6/lib/thor/base.rb:389:in `start'
[2012/01/15 09:25:44][error] /Users/jdyer/.rvm/gems/ruby-1.9.3-p0@global/gems/backup-3.0.20/bin/backup:11:in `'
[2012/01/15 09:25:44][error] /Users/jdyer/.rvm/gems/ruby-1.9.3-p0@global/bin/backup:19:in `load'
[2012/01/15 09:25:44][error] /Users/jdyer/.rvm/gems/ruby-1.9.3-p0@global/bin/backup:19:in `

'
[2012/01/15 09:25:44][message] ModelError: If you have other Backup jobs (triggers) configured to run,
[2012/01/15 09:25:44][message] Backup will now attempt to continue...
[2012/01/15 09:25:44][message] Backup::Notifier::Mail started notifying about the process.
[2012/01/15 09:25:44][message] Backup::Cleaner started cleaning up the temporary files.

Config.rb
============

# encoding: utf-8

##
# Backup
# Generated Main Config Template
#
# For more information:
#
# View the Git repository at https://github.com/meskyanichi/backup
# View the Wiki/Documentation at https://github.com/meskyanichi/backup/wiki
# View the issue log at https://github.com/meskyanichi/backup/issues

##
# Global Configuration
# Add more (or remove) global configuration below
Backup::Configuration::Storage::S3.defaults do |s3|
s3.access_key_id = "____"
s3.secret_access_key = "_____"
end

Backup::Configuration::Encryptor::OpenSSL.defaults do |encryption|
encryption.password = "_____"
encryption.base64 = true
encryption.salt = true
end

Backup::Configuration::Compressor::Gzip.defaults do |compression|
compression.best = true
end

##
# Load all models from the models directory (after the above global configuration blocks)
Dir[File.join(File.dirname(Backup::CONFIG_FILE), "models", "*.rb")].each do |model|
instance_eval(File.read(model))
end

Backup::Configuration::Notifier::Mail.defaults do |mail|
mail.from = 'donotreply@mydomain.com'
mail.to = 'jdyer@mydomain.com'
mail.address = 'smtp.gmail.com'
mail.port = 587
mail.domain = 'mydomain.com'
mail.user_name = 'donotreply@mydomain.com'
mail.password = 'password'
mail.authentication = 'plain'
mail.enable_starttls_auto = true
end

jenkins.rb
=====

# encoding: utf-8

##
# Backup Generated: test
# Once configured, you can run the backup with the following command:
#
# $ backup perform -t test [-c ]
#
Backup::Model.new(:jenkins, 'Jenkins config backups') do
compress_with Gzip
encrypt_with OpenSSL
# notify_by Mail

##
# Split [Splitter]
#
# Split the backup file in to chunks of 250 megabytes
# if the backup file size exceeds 250 megabytes
#
split_into_chunks_of 250

archive :jenkins_config do |archive|
archive.add '/tmp'#'/.jenkins'
# archive.exclude '/data/.jenkins/jobs/'
end

store_with S3 do |s3|
s3.bucket = "labs-backups"
s3.path = "/test"
s3.keep = 10
end

notify_by Mail do |mail|
mail.on_success = true
mail.on_warning = true
mail.on_failure = true
end
end

If I put the notification config directly in the model, copy and paste, it works fine

# encoding: utf-8

##
# Backup Generated: test
# Once configured, you can run the backup with the following command:
#
# $ backup perform -t test [-c ]
#
Backup::Model.new(:jenkins, 'Jenkins config backups') do
compress_with Gzip
encrypt_with OpenSSL
# notify_by Mail

##
# Split [Splitter]
#
# Split the backup file in to chunks of 250 megabytes
# if the backup file size exceeds 250 megabytes
#
split_into_chunks_of 250

archive :jenkins_config do |archive|
archive.add '/tmp'#'/.jenkins'
# archive.exclude '/data/.jenkins/jobs/'
end

store_with S3 do |s3|
s3.bucket = "labs-backups"
s3.path = "/test"
s3.keep = 10
end

notify_by Mail do |mail|
mail.on_success = true
mail.on_warning = true
mail.on_failure = true
mail.from = 'donotreply@domain.com'
mail.to = 'jdyer@domain.com'
mail.address = 'smtp.gmail.com'
mail.port = 587
mail.domain = 'domain.com'
mail.user_name = 'donotreply@domain.com'
mail.password = 'pass'
mail.authentication = 'plain'
mail.enable_starttls_auto = true
end
end