Method: Geordi::Remote#dump

Defined in:
lib/geordi/remote.rb

#dump(options = {}) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/geordi/remote.rb', line 34

def dump(options = {})
  # 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)

  note "Downloading remote dump to #{relative_destination} ..."
  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