Class: Webbynode::Commands::AddBackup

Inherits:
Webbynode::Command show all
Defined in:
lib/webbynode/commands/add_backup.rb

Constant Summary

Constants inherited from Webbynode::Command

Webbynode::Command::Aliases, Webbynode::Command::CommandError, Webbynode::Command::InvalidCommand, Webbynode::Command::InvalidOption, Webbynode::Command::Settings

Instance Method Summary collapse

Methods inherited from Webbynode::Command

add_alias, #api, class_for, command, command_class_name, description, for, #gemfile, #git, help, inherited, #initialize, #io, #no?, #notify, option, #option, #options, options_help, #param, #param_values, parameter, #params, #params_hash, params_help, #pushand, #remote_executor, requires_initialization!, requires_options!, requires_pushed_application!, #run, #server, setting, #settings, summary, summary_help, usage, #validate_initialization, #validate_options, #yes?

Constructor Details

This class inherits a constructor from Webbynode::Command

Instance Method Details

#executeObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/webbynode/commands/add_backup.rb', line 6

def execute
  key    = io.general_settings['aws_key']   
  secret = io.general_settings['aws_secret']
  
  unless key and secret
    io.log io.read_from_template("backup")
    
    key    = ask("AWS key: ")
    secret = ask("AWS secret: ") unless key.blank?
    
    if key.blank? or secret.blank?
      puts 
      puts "Aborted."
      return
    end
    
    io.add_general_setting("aws_key", key)
    io.add_general_setting("aws_secret", secret)
  end

  app_name = pushand.parse_remote_app_name
  io.log "Configuring backup for #{app_name}...", :start
  
  retain = option(:retain)
  remote_executor.exec %Q(config_app_backup #{app_name} "#{key}" "#{secret}"#{retain.blank? ? "" : " #{retain}"}), true
end