Class: Backup::Database::Riak

Inherits:
Base
  • Object
show all
Defined in:
lib/backup/database/riak.rb

Constant Summary

Constants included from CLI::Helpers

CLI::Helpers::UTILITY

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Configuration::Helpers

included

Constructor Details

#initialize(model, &block) ⇒ Riak

Creates a new instance of the Riak adapter object



29
30
31
32
33
34
35
# File 'lib/backup/database/riak.rb', line 29

def initialize(model, &block)
  super(model)

  instance_eval(&block) if block_given?

  @riak_admin_utility ||= utility('riak-admin')
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Backup::Configuration::Helpers

Instance Attribute Details

Cookie is the Erlang cookie/shared secret used to connect to the node.



17
18
19
# File 'lib/backup/database/riak.rb', line 17

def cookie
  @cookie
end

#nameObject

Name is the name of the backup



9
10
11
# File 'lib/backup/database/riak.rb', line 9

def name
  @name
end

#nodeObject

Node is the node from which to perform the backup.



13
14
15
# File 'lib/backup/database/riak.rb', line 13

def node
  @node
end

#riak_admin_utilityObject

Path to riak-admin utility (optional)



21
22
23
# File 'lib/backup/database/riak.rb', line 21

def riak_admin_utility
  @riak_admin_utility
end

Instance Method Details

#perform!Object

Performs the riak-admin command and outputs the data to the specified path based on the ‘trigger’



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/backup/database/riak.rb', line 40

def perform!
  super
  # have to make riak the owner since the riak-admin tool runs
  # as the riak user in a default setup.
  FileUtils.chown_R('riak', 'riak', @dump_path)

  backup_file = File.join(@dump_path, name)
  run("#{ riakadmin } #{ backup_file } node")

  if @model.compressor
    @model.compressor.compress_with do |command, ext|
      run("#{ command } -c #{ backup_file } > #{ backup_file + ext }")
      FileUtils.rm_f(backup_file)
    end
  end
end