Class: Outback::SftpTarget
Instance Attribute Summary collapse
-
#host ⇒ Object
readonly
Returns the value of attribute host.
Attributes inherited from Target
Instance Method Summary collapse
-
#initialize(backup_name, host) ⇒ SftpTarget
constructor
A new instance of SftpTarget.
- #put(archives) ⇒ Object
- #to_s ⇒ Object
- #valid? ⇒ Boolean
Methods inherited from Target
Methods included from Logging
Methods included from Configurable
Constructor Details
#initialize(backup_name, host) ⇒ SftpTarget
Returns a new instance of SftpTarget.
9 10 11 12 |
# File 'lib/outback/sftp_target.rb', line 9 def initialize(backup_name, host) super(backup_name) @host = host end |
Instance Attribute Details
#host ⇒ Object (readonly)
Returns the value of attribute host.
6 7 8 |
# File 'lib/outback/sftp_target.rb', line 6 def host @host end |
Instance Method Details
#put(archives) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/outback/sftp_target.rb', line 22 def put(archives) size = count = 0 connect do archives.each do |archive| basename = archive.filename.basename.to_s upload_filename = path ? File.join(path, basename) : basename logger.debug "SftpTarget: storing #{archive.filename} in sftp://#{user}@#{host}#{':' + port.to_s if port}:#{upload_filename}" connection.upload!(archive.filename.to_s, upload_filename) size += archive.size count += 1 end end logger.info "Uploaded #{count} archives (#{size} bytes) to #{self}" count end |
#to_s ⇒ Object
18 19 20 |
# File 'lib/outback/sftp_target.rb', line 18 def to_s "sftp:#{user}@#{host}#{':' + port.to_s if port}:#{path}" end |
#valid? ⇒ Boolean
14 15 16 |
# File 'lib/outback/sftp_target.rb', line 14 def valid? host.present? end |