Class: Imap::Backup::Account::Backup
- Inherits:
-
Object
- Object
- Imap::Backup::Account::Backup
- Defined in:
- lib/imap/backup/account/backup.rb
Overview
Carries out the backup of the configured folders of the account
Instance Method Summary collapse
-
#initialize(account:, refresh: false) ⇒ Backup
constructor
A new instance of Backup.
-
#run ⇒ void
Runs the backup.
Constructor Details
#initialize(account:, refresh: false) ⇒ Backup
Returns a new instance of Backup.
13 14 15 16 |
# File 'lib/imap/backup/account/backup.rb', line 13 def initialize(account:, refresh: false) @account = account @refresh = refresh end |
Instance Method Details
#run ⇒ void
This method returns an undefined value.
Runs the backup
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/imap/backup/account/backup.rb', line 20 def run Logger.logger.info "Running backup of account '#{account.username}'" # start the connection so we get logging messages in the right order account.client.login run_pre_backup_tasks backup_folders = Account::BackupFolders.new( client: account.client, account: account ).to_a if backup_folders.none? Logger.logger.warn "No folders found to backup for account '#{account.username}'" return end Logger.logger.debug "Starting backup of #{backup_folders.count} folders" backup_folders.each do |folder| Account::FolderBackup.new(account: account, folder: folder, refresh: refresh).run end Logger.logger.debug "Backup of account '#{account.username}' complete" end |