lib/backup/remote/command.rb in backup-remote-0.0.18 vs lib/backup/remote/command.rb in backup-remote-0.0.19

- old
+ new

@@ -23,11 +23,10 @@ host end def run_ssh_cmd(hostname, ssh_options, cmd) - #puts "run ssh cmd: #{hostname}, #{ssh_user}, #{ssh_pass}, #{cmd}" host = Command.build_sshkit_host(hostname, ssh_options) #srv = ssh_user+'@'+hostname all_servers = [host] @@ -45,17 +44,17 @@ output = capture(cmd) end end =end - puts "output: #{output}" + #puts "output: #{output}" # return { res: 1, output: output } rescue => e - puts "ssh error: #{e.message}, #{e.backtrace}" + #puts "ssh error: #{e.message}, #{e.backtrace}" { res: 0, output: output, error: e.message @@ -131,25 +130,25 @@ res: 0, error: e.message } end - def ssh_upload_file(hostname, ssh_options, source_file, dest_file, handler=nil) - host = Command.build_sshkit_host(hostname, ssh_options) + def ssh_upload_file(hostname, ssh_options, source_file, dest_file, handler=nil) + host = Command.build_sshkit_host(hostname, ssh_options) - # scp - f_temp = "/tmp/#{SecureRandom.uuid}" + # scp + f_temp = "/tmp/#{SecureRandom.uuid}" - # sshkit - SSHKit::Coordinator.new(host).each in: :sequence do - # upload to temp file - upload! source_file, f_temp + # sshkit + SSHKit::Coordinator.new(host).each in: :sequence do + # upload to temp file + upload! source_file, f_temp - # upload to dest - execute("cp #{f_temp} #{dest_file}", interaction_handler: handler) + # upload to dest + execute("cp #{f_temp} #{dest_file}", interaction_handler: handler) - end + end =begin on host do |host| # NOT WORK with sudo #upload! source_file, dest_file @@ -164,17 +163,17 @@ end end =end - # - return {res: 1, output: ""} + # + return {res: 1, output: ""} rescue => e { res: 0, error: e.message } - end + end end end end