Sha256: 3bec3a5f716bb82896ab4247716005b1e231588ae5d317d36288382b9b5eb1e7

Contents?: true

Size: 874 Bytes

Versions: 5

Compression:

Stored size: 874 Bytes

Contents

module Backup
  module Storage
    class SCP
      
      attr_accessor :user, :password, :ip, :path, :tmp_path, :final_file
      
      # Stores the backup file on the remote server using SCP
      def initialize(adapter)
        %w(ip user password path).each do |method|
          send("#{method}=", adapter.procedure.get_storage_configuration.attributes[method])
        end
        
        final_file = adapter.final_file
        tmp_path   = adapter.tmp_path
        
        Net::SSH.start(ip, user, :password => password) do |ssh|
          ssh.exec "mkdir -p #{path}"
        end
        
        puts "Storing \"#{final_file}\" to path \"#{path}\" on remote server (#{ip})."
        Net::SCP.start(ip, user, :password => password) do |scp|
          scp.upload! File.join(tmp_path, final_file).gsub('\ ', ' '), path
        end
      end
      
    end
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
backup-gundua-2.3.1.2 lib/backup/storage/scp.rb
backup-gundua-2.3.1.1 lib/backup/storage/scp.rb
backup-2.3.1 lib/backup/storage/scp.rb
backup-2.3.0.3 lib/backup/storage/scp.rb
backup-2.3.0.2 lib/backup/storage/scp.rb