Class: Backup::Database::Riak
Instance Attribute Summary collapse
-
#cookie ⇒ Object
Cookie is the Erlang cookie/shared secret used to connect to the node.
-
#node ⇒ Object
Node is the node from which to perform the backup.
-
#user ⇒ Object
Username for the riak instance Default: riak.
Attributes inherited from Base
#database_id, #dump_path, #model
Instance Method Summary collapse
-
#initialize(model, database_id = nil, &block) ⇒ Riak
constructor
A new instance of Riak.
-
#perform! ⇒ Object
Performs the dump using ‘riak-admin backup`.
Methods included from Config::Helpers
Methods included from Utilities::Helpers
Constructor Details
#initialize(model, database_id = nil, &block) ⇒ Riak
Returns a new instance of Riak.
22 23 24 25 26 27 28 29 |
# File 'lib/backup/database/riak.rb', line 22 def initialize(model, database_id = nil, &block) super instance_eval(&block) if block_given? @node ||= '[email protected]' @cookie ||= 'riak' @user ||= 'riak' end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Backup::Config::Helpers
Instance Attribute Details
#cookie ⇒ Object
Cookie is the Erlang cookie/shared secret used to connect to the node. Default: riak
15 16 17 |
# File 'lib/backup/database/riak.rb', line 15 def @cookie end |
#node ⇒ Object
Node is the node from which to perform the backup. Default: [email protected]
10 11 12 |
# File 'lib/backup/database/riak.rb', line 10 def node @node end |
#user ⇒ Object
Username for the riak instance Default: riak
20 21 22 |
# File 'lib/backup/database/riak.rb', line 20 def user @user end |
Instance Method Details
#perform! ⇒ Object
Performs the dump using ‘riak-admin backup`.
This will be stored in the final backup package as <trigger>/databases/<dump_filename>-<node>
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/backup/database/riak.rb', line 36 def perform! super dump_file = File.join(dump_path, dump_filename) with_riak_owned_dump_path do run("#{ riakadmin } backup #{ node } #{ } '#{ dump_file }' node") end model.compressor.compress_with do |command, ext| dump_file << "-#{ node }" # `riak-admin` appends `node` to the filename. run("#{ command } -c '#{ dump_file }' > '#{ dump_file + ext }'") FileUtils.rm_f(dump_file) end if model.compressor log!(:finished) end |