Class: Scp

Inherits:
Rehabilitate::Plugin show all
Defined in:
lib/rehabilitate/plugins/scp.rb

Instance Method Summary collapse

Methods inherited from Rehabilitate::Plugin

derivative_dirs, #log

Instance Method Details

#upload(options) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/rehabilitate/plugins/scp.rb', line 7

def upload(options)
  location = parse_upload_string(options.location)
  remote_dir = "#{location[:dir]}/#{options._base_backup_name}"
  log "Connecting to #{location[:host]} with user: #{location[:user]}:#{location[:pass]}"

  options._backup_files.collect! do |local_file|
    remote_file = "#{remote_dir}/#{File.basename(local_file)}"
    log "Uploading '#{local_file}' to '#{remote_file}'"
    Net::SCP.upload!( location[:host], 
                      location[:user], 
                      local_file, 
                      remote_file,
                      :password => location[:pass],
                      :recursive => true )
  end
end