Class: P2bBackup::Providers::Sftp
- Inherits:
-
Object
- Object
- P2bBackup::Providers::Sftp
- Defined in:
- lib/p2b-backup/providers/sftp.rb
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ Sftp
constructor
A new instance of Sftp.
- #upload(path, filename: 'file.sql.gz') ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ Sftp
Returns a new instance of Sftp.
6 7 8 |
# File 'lib/p2b-backup/providers/sftp.rb', line 6 def initialize(opts = {}) @opts = opts end |
Instance Method Details
#upload(path, filename: 'file.sql.gz') ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/p2b-backup/providers/sftp.rb', line 10 def upload(path, filename: 'file.sql.gz') Net::SFTP.start(@opts[:host], @opts[:username], password: @opts[:password]) do |sftp| # upload a file or directory to the remote host sftp.upload!(path, "#{@opts[:path]}/#{filename}") end puts "Uploaded to #{@bucket}" end |