Class: Siba::Source::Mysql::Init

Inherits:
Object
  • Object
show all
Includes:
LoggerPlug
Defined in:
lib/siba-source-mysql/init.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Init

Returns a new instance of Init.



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/siba-source-mysql/init.rb', line 29

def initialize(options)
  parsed_options = {}
  OPTION_NAMES.each do |option_name|
    if MULTIPLE_CHOISES.include? option_name
      value = Siba::SibaCheck.options_string_array options, option_name.to_s, true
    else
      value = Siba::SibaCheck.options_string options, option_name.to_s, true
      if value.nil?
        # try get the setting from environment variable
        value = ENV["#{ENV_PREFIX}#{option_name.to_s.upcase}"]
      end
    end
    parsed_options[option_name] = value
  end

  @db = Siba::Source::Mysql::Db.new parsed_options
end

Instance Attribute Details

#dbObject

Returns the value of attribute db.



27
28
29
# File 'lib/siba-source-mysql/init.rb', line 27

def db
  @db
end

Instance Method Details

#backup(dest_dir) ⇒ Object

Collect source files and put them into dest_dir No return value is expected



49
50
51
52
# File 'lib/siba-source-mysql/init.rb', line 49

def backup(dest_dir)
  logger.info "Dumping MySQL#{db.db_and_table_names}"
  @db.backup dest_dir
end

#restore(from_dir) ⇒ Object

Restore source files from_dir No return value is expected



56
57
58
59
# File 'lib/siba-source-mysql/init.rb', line 56

def restore(from_dir)
  logger.info "Restoring MySQL#{db.db_and_table_names}"
  @db.restore from_dir
end