class Siba::Destination::Ftp::Init
Constants
- DEFAULT_FTP_HOST_ENV_NAME
- DEFAULT_FTP_PASSWORD_ENV_NAME
- DEFAULT_FTP_USER_ENV_NAME
Attributes
worker[RW]
Public Class Methods
new(options)
click to toggle source
# File lib/siba-destination-ftp/init.rb, line 15 def initialize(options) host = Siba::SibaCheck.options_string options, "host" user = Siba::SibaCheck.options_string options, "user", true, ENV[DEFAULT_FTP_USER_ENV_NAME] password = Siba::SibaCheck.options_string options, "password", true, ENV[DEFAULT_FTP_PASSWORD_ENV_NAME] directory = Siba::SibaCheck.options_string options, "dir", true, "/" passive = Siba::SibaCheck.options_bool options, "passive", true, false @worker = Siba::Destination::Ftp::Worker.new host, user, password, directory, passive end
Public Instance Methods
backup(path_to_backup_file)
click to toggle source
Put backup file (path_to_backup_file) to destination No return value is expected
# File lib/siba-destination-ftp/init.rb, line 26 def backup(path_to_backup_file) logger.info "Uploading backup to FTP: #{worker.user_host_and_dir}" @worker.connect_and_put_file path_to_backup_file end
get_backups_list(backup_name)
click to toggle source
Shows the list of files stored currently at destination with file names starting with ‘backup_name’
Returns an array of two-element arrays:
- backup_file_name, modification_time
# File lib/siba-destination-ftp/init.rb, line 36 def get_backups_list(backup_name) logger.info "Getting the list of backups from FTP: #{worker.user_host_and_dir}" @worker.get_files_list backup_name end
restore(backup_name, dir)
click to toggle source
Restoring: put backup file into dir
# File lib/siba-destination-ftp/init.rb, line 42 def restore(backup_name, dir) logger.info "Downloading backup from FTP: #{worker.user_host_and_dir}" @worker.connect_and_get_file backup_name, File.join(dir, backup_name) end