Class: Mys3ql::Conductor

Inherits:
Object
  • Object
show all
Defined in:
lib/mys3ql/conductor.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config_file = nil) ⇒ Conductor

Returns a new instance of Conductor.



15
16
17
18
19
# File 'lib/mys3ql/conductor.rb', line 15

def initialize(config_file = nil)
  @config = Config.new(config_file)
  @mysql = Mysql.new @config
  @s3 = S3.new @config
end

Class Method Details

.run(command, config, debug) ⇒ Object



9
10
11
12
13
# File 'lib/mys3ql/conductor.rb', line 9

def self.run(command, config, debug)
  conductor = Conductor.new(config)
  conductor.debug = debug
  conductor.send command
end

Instance Method Details

#debug=(val) ⇒ Object



54
55
56
# File 'lib/mys3ql/conductor.rb', line 54

def debug=(val)
  @config.debug = val
end

#fullObject



21
22
23
24
25
26
# File 'lib/mys3ql/conductor.rb', line 21

def full
  @mysql.dump
  @s3.store @mysql.dump_file
  @mysql.delete_dump
  @s3.delete_bin_logs
end

#incrementalObject



28
29
30
31
32
# File 'lib/mys3ql/conductor.rb', line 28

def incremental
  @mysql.each_bin_log do |log|
    @s3.store log, false
  end
end

#restoreObject

for now only restore from latest



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/mys3ql/conductor.rb', line 35

def restore
  # get latest dump
  with_temp_file do |file|
    @s3.retrieve :latest, file
    @mysql.restore file
  end

  # apply subsequent bin logs
  @s3.each_bin_log do |log|
    with_temp_file do |file|
      @s3.retrieve log, file
      @mysql.apply_bin_log file
    end
  end

  # NOTE: not sure about this:
  puts "You might want to flush mysql's logs..."
end