Class: Backup::Storage::FTP
Instance Attribute Summary collapse
-
#final_file ⇒ Object
Returns the value of attribute final_file.
-
#ip ⇒ Object
Returns the value of attribute ip.
-
#password ⇒ Object
Returns the value of attribute password.
-
#path ⇒ Object
Returns the value of attribute path.
-
#tmp_path ⇒ Object
Returns the value of attribute tmp_path.
-
#user ⇒ Object
Returns the value of attribute user.
Instance Method Summary collapse
-
#initialize(adapter) ⇒ FTP
constructor
Stores the backup file on the remote server using FTP.
Methods included from CommandHelper
Constructor Details
#initialize(adapter) ⇒ FTP
Stores the backup file on the remote server using FTP
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/backup/storage/ftp.rb', line 10 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::FTP.open(ip, user, password) do |ftp| begin ftp.chdir(path) rescue puts "Could not find or access \"#{path}\" on \"#{ip}\", please ensure this directory exists and is accessible by the user \"#{user}\"." exit end begin puts "Storing \"#{final_file}\" to path \"#{path}\" on remote server (#{ip})." ftp.putbinaryfile(File.join(tmp_path, final_file).gsub('\ ', ' '), File.join(path, final_file)) rescue puts "Could not save file to backup server. Is the \"#{path}\" directory writable?" exit end end end |
Instance Attribute Details
#final_file ⇒ Object
Returns the value of attribute final_file.
7 8 9 |
# File 'lib/backup/storage/ftp.rb', line 7 def final_file @final_file end |
#ip ⇒ Object
Returns the value of attribute ip.
7 8 9 |
# File 'lib/backup/storage/ftp.rb', line 7 def ip @ip end |
#password ⇒ Object
Returns the value of attribute password.
7 8 9 |
# File 'lib/backup/storage/ftp.rb', line 7 def password @password end |
#path ⇒ Object
Returns the value of attribute path.
7 8 9 |
# File 'lib/backup/storage/ftp.rb', line 7 def path @path end |
#tmp_path ⇒ Object
Returns the value of attribute tmp_path.
7 8 9 |
# File 'lib/backup/storage/ftp.rb', line 7 def tmp_path @tmp_path end |
#user ⇒ Object
Returns the value of attribute user.
7 8 9 |
# File 'lib/backup/storage/ftp.rb', line 7 def user @user end |