Class: Backup::Database::Riak
Constant Summary
Constants included from CLI::Helpers
Instance Attribute Summary collapse
-
#cookie ⇒ Object
Cookie is the Erlang cookie/shared secret used to connect to the node.
-
#name ⇒ Object
Name is the name of the backup.
-
#node ⇒ Object
Node is the node from which to perform the backup.
-
#riak_admin_utility ⇒ Object
Path to riak-admin utility (optional).
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(model, &block) ⇒ Riak
constructor
Creates a new instance of the Riak adapter object.
-
#perform! ⇒ Object
Performs the riak-admin command and outputs the data to the specified path based on the ‘trigger’.
Methods included from Configuration::Helpers
#clear_defaults!, #load_defaults!
Methods included from CLI::Helpers
#command_name, #raise_if_command_failed!, #run, #utility
Constructor Details
#initialize(model, &block) ⇒ Riak
Creates a new instance of the Riak adapter object
25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/backup/database/riak.rb', line 25 def initialize(model, &block) super(model) instance_eval(&block) if block_given? if @utility_path Logger.warn "[DEPRECATED] " + "Database::Riak#utility_path has been deprecated.\n" + " Use Database::Riak#riak_admin_utility instead." @riak_admin_utility ||= @utility_path end @riak_admin_utility ||= utility('riak-admin') end |
Instance Attribute Details
#cookie ⇒ Object
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 end |
#name ⇒ Object
Name is the name of the backup
9 10 11 |
# File 'lib/backup/database/riak.rb', line 9 def name @name end |
#node ⇒ Object
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_utility ⇒ Object
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’
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/backup/database/riak.rb', line 42 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 |