Class: Siba::Destination::Ftp::Init
- Inherits:
-
Object
- Object
- Siba::Destination::Ftp::Init
- Includes:
- LoggerPlug
- Defined in:
- lib/siba-destination-ftp/init.rb
Constant Summary collapse
- DEFAULT_FTP_HOST_ENV_NAME =
"SIBA_FTP_HOST"
- DEFAULT_FTP_USER_ENV_NAME =
"SIBA_FTP_USER"
- DEFAULT_FTP_PASSWORD_ENV_NAME =
"SIBA_FTP_PASSWORD"
Instance Attribute Summary collapse
-
#worker ⇒ Object
Returns the value of attribute worker.
Instance Method Summary collapse
-
#backup(path_to_backup_file) ⇒ Object
Put backup file (path_to_backup_file) to destination No return value is expected.
-
#get_backups_list(backup_name) ⇒ Object
Shows the list of files stored currently at destination with file names starting with ‘backup_name’.
-
#initialize(options) ⇒ Init
constructor
A new instance of Init.
-
#restore(backup_name, dir) ⇒ Object
Restoring: put backup file into dir.
Constructor Details
#initialize(options) ⇒ Init
Returns a new instance of Init.
15 16 17 18 19 20 21 22 |
# File 'lib/siba-destination-ftp/init.rb', line 15 def initialize() host = Siba::SibaCheck. , "host" user = Siba::SibaCheck. , "user", true, ENV[DEFAULT_FTP_USER_ENV_NAME] password = Siba::SibaCheck. , "password", true, ENV[DEFAULT_FTP_PASSWORD_ENV_NAME] directory = Siba::SibaCheck. , "dir", true, "/" passive = Siba::SibaCheck. , "passive", true, false @worker = Siba::Destination::Ftp::Worker.new host, user, password, directory, passive end |
Instance Attribute Details
#worker ⇒ Object
Returns the value of attribute worker.
9 10 11 |
# File 'lib/siba-destination-ftp/init.rb', line 9 def worker @worker end |
Instance Method Details
#backup(path_to_backup_file) ⇒ Object
Put backup file (path_to_backup_file) to destination No return value is expected
26 27 28 29 |
# 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) ⇒ Object
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
36 37 38 39 |
# 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) ⇒ Object
Restoring: put backup file into dir
42 43 44 45 |
# 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 |