Method: FileCopy.sftp_copy

Defined in:
lib/file_copy/copy.rb

.sftp_copy(username, password, server, files_map) ⇒ Object

Simply copy map files using sftp server on dest_server. Note: stfp.upload support parallel uploads - default is 2. TODO(kolman): packing files, all, not all, determine by part of file.



34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/file_copy/copy.rb', line 34

def sftp_copy(username, password, server, files_map)
  ssh = FileCopy.ssh_connect(username, password, server)
  ssh.sftp.connect do |sftp|
    uploads = files_map.map { |from,to|
      remote_dir = File.dirname(to)
      sftp_mkdir_recursive(sftp, File.dirname(to))
      Log.debug1("Copying %s to %s",from, to)
      sftp.upload(from, to)
    }
    uploads.each { |u| u.wait }
    Log.debug1("Done.")
  end # ssh.sftp.connect
end