Skip to content

Commit

Permalink
keep appended node name when compressing riak dump file
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian D. Burns committed Feb 25, 2013
1 parent a55c1ac commit 752b4f4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
12 changes: 8 additions & 4 deletions lib/backup/database/riak.rb
Expand Up @@ -45,8 +45,11 @@ def initialize(model, &block)
end

##
# Performs the riak-admin command and outputs the
# data to the specified path based on the 'trigger'
# Performs the `riak-admin` command which creates a single dump file in
# @dump_path based on the `name` and `node`.
#
# `riak-admin` will append the `node` to the filename.
# i.e. <tmp_path>/<trigger>/databases/Riak/<name>-<node>
def perform!
super
# ensure riak-admin user has permissions to write backup file
Expand All @@ -57,8 +60,9 @@ def perform!

if @model.compressor
@model.compressor.compress_with do |command, ext|
run("#{ command } -c #{ backup_file }-#{ node } > #{ backup_file + ext }")
FileUtils.rm_f("#{ backup_file }-#{ node }")
backup_file << "-#{ node }"
run("#{ command } -c #{ backup_file } > #{ backup_file + ext }")
FileUtils.rm_f(backup_file)
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions spec/database/riak_spec.rb
Expand Up @@ -135,8 +135,8 @@
db.expects(:run).in_sequence(s).
with('riakadmin_command /dump/path/mydatabase node')
db.expects(:run).in_sequence(s).with(
"compressor_command -c " +
"/dump/path/mydatabase-riak@localhost > /dump/path/mydatabase.gz"
"compressor_command -c /dump/path/mydatabase-riak@localhost > " +
"/dump/path/mydatabase-riak@localhost.gz"
)
FileUtils.expects(:rm_f).in_sequence(s).
with('/dump/path/mydatabase-riak@localhost')
Expand Down

0 comments on commit 752b4f4

Please sign in to comment.