lib/geordi/remote.rb in geordi-1.2.3 vs lib/geordi/remote.rb in geordi-1.3.0
- old
+ new
@@ -30,20 +30,24 @@
puts
selected_server
end
def dump(options = {})
- shell(options.merge :remote_command => "dumple #{@config.env} --for_download")
+ # Generate dump on the server
+ shell options.merge({
+ :remote_command => "dumple #{@config.env} --for_download",
+ :select_server => nil # Dump must be generated on the primary server
+ })
destination_directory = File.join(@config.root, 'tmp')
FileUtils.mkdir_p destination_directory
destination_path = File.join(destination_directory, "#{@stage}.dump")
relative_destination = Pathname.new(destination_path).relative_path_from Pathname.new(@config.root)
- puts
note "Downloading remote dump to #{relative_destination} ..."
- Util.system! "scp #{@config.user}@#{@config.primary_server}:#{REMOTE_DUMP_PATH} #{destination_path}"
+ server = @config.primary_server
+ Util.system! "scp #{ @config.user(server) }@#{ server }:#{REMOTE_DUMP_PATH} #{destination_path}"
success "Dumped the #{@stage} database to #{relative_destination}."
destination_path
end
@@ -53,14 +57,14 @@
end
def shell(options = {})
server = options[:select_server] ? select_server : @config.primary_server
- remote_command = "cd #{@config.path} && #{@config.shell}"
+ remote_command = "cd #{@config.remote_root} && #{@config.shell}"
remote_command << " -c '#{options[:remote_command]}'" if options[:remote_command]
note 'Connecting to ' + server.to_s
- Util.system! 'ssh', "#{@config.user}@#{server}", '-t', remote_command
+ Util.system! 'ssh', "#{ @config.user(server) }@#{ server }", '-t', remote_command
end
end
end