Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Notifiers

meskyanichi edited this page · 24 revisions

Notifiers

Currently supported notifiers:

  • Mail
  • Twitter
  • Campfire
  • Presently

Examples

Below are examples you can copy/paste in to your "Backup" configuration file. These blocks should be placed between Backup::Model.new(:my_backup, 'My Backup') do and end.

Mail

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

  mail.from                 = 'sender@email.com'
  mail.to                   = 'receiver@email.com'
  mail.address              = 'smtp.gmail.com'
  mail.port                 = 587
  mail.domain               = 'your.host.name'
  mail.user_name            = 'sender@email.com'
  mail.password             = 'my_password'
  mail.authentication       = 'plain'
  mail.enable_starttls_auto = true
end

This will make sender@email.com send an email to receiver@email.com every time a Backup process ends with, or without any errors.

In case a Backup process succeeds without any errors, it'll notify receiver@email.com with a plain email. In case a Backup process raises an error, it'll (try to) notify receiver@email.com with a more detailed email that includes the raised exception name, the backtrace, the Ruby version, the Backup Gem version, etc. for debugging purposes.

Twitter

notify_by Twitter do |tweet|
  tweet.on_success = true
  tweet.on_failure = true

  tweet.consumer_key       = 'my_consumer_key'
  tweet.consumer_secret    = 'my_consumer_secret'
  tweet.oauth_token        = 'my_oauth_token'
  tweet.oauth_token_secret = 'my_oauth_token_secret'
end

In order to use Twitter as a notifier you will need a Twitter account. Once you create a Twitter account for the notifier, you need to register a new application for your Twitter account. After registering an application you will acquire the following credentials:

  • consumer_key
  • my_consumer_secret
  • my_oauth_token
  • my_oauth_token_secret

You can find these credentials on your application's pages.

Campfire

notify_by Campfire do |campfire|
  campfire.on_success = true
  campfire.on_failure = true

  campfire.api_token = 'my_token'
  campfire.subdomain = 'my_subdomain'
  campfire.room_id   = 'the_room_id'
end

In order to use Campfire as a notifier you will need a Campfire account. Once you create a Campfire account for the notifier, you need to create a room and take note of it's id (room_id) (https://.campfirenow.com/room/), get your api authentication token from the "My info" page, and take not of your subdomain (https://.campfirenow.com/). Long story short, this is the information you will need:

  • api authentication token
  • subdomain
  • room id

Presently

notify_by Presently do |presently|
  presently.on_success = true
  presently.on_failure = true

  presently.subdomain = 'my_subdomain'
  presently.user_name = 'my_user_name'
  presently.password  = 'my_password'
  presently.group_id  = 'my_group_id' # optional
end

In order to use Presently as a notifier you will need a Presently account.

Default Configuration for each notifier

If you are planning to set up a Mail notifier for multiple Backup processes, it'll become quite verbose and redundant, very quickly. Consider setting up some default configuration. For example, if in most cases you want to use the same "sender" to send email notifications, you could set up a default Mail configuration, like so:

Backup::Configuration::Notifier::Mail.defaults do |mail|
  mail.from                 = 'sender@email.com'
  mail.to                   = 'receiver@email.com'
  mail.address              = 'smtp.gmail.com'
  mail.port                 = 587
  mail.domain               = 'your.host.name'
  mail.user_name            = 'sender@email.com'
  mail.password             = 'my_password'
  mail.authentication       = 'plain'
  mail.enable_starttls_auto = true
end

So now, every time you wish to setup Mail notifications for a Backup process, you only have to define the following inside the Backup::Model block

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

and you won't have to specify all the SMTP configuration, sender, receiver, credentials, etc. It'll always use these as default unless you explicitly overwrite them within the notify_by block.

Something went wrong with that request. Please try again.