Class: Imap::Backup::Account::Backup

Inherits:
Object
  • Object
show all
Defined in:
lib/imap/backup/account/backup.rb

Overview

Carries out the backup of the configured folders of the account

Instance Method Summary collapse

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 = 
  @refresh = refresh
end

Instance Method Details

#runObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/imap/backup/account/backup.rb', line 18

def run
  Logger.logger.info "Running backup of account: #{.username}"
  # start the connection so we get logging messages in the right order
  .client.

  Account::FolderEnsurer.new(account: ).run
  Account::LocalOnlyFolderDeleter.new(account: ).run if .mirror_mode
  backup_folders = Account::BackupFolders.new(
    client: .client, account: 
  )
  if backup_folders.none?
    Logger.logger.warn "Account #{.username}: No folders found to backup"
    return
  end
  backup_folders.each do |folder|
    Account::FolderBackup.new(account: , folder: folder, refresh: refresh).run
  end
end