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.

Parameters:

  • account (Account)

    the account to back up

  • refresh (Boolean) (defaults to: false)

    true to refresh folder metadata even if mirror is disabled



15
16
17
18
# File 'lib/imap/backup/account/backup.rb', line 15

def initialize(account:, refresh: false)
  @account = 
  @refresh = refresh
end

Instance Method Details

#runvoid

This method returns an undefined value.

Runs the backup



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 22

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

  ensure_directory
  delete_local_only_folders if .mirror_mode

  if backup_folders.none?
    Logger.logger.warn "No folders found to backup for account '#{account.username}'"
    return
  end

  locker.with_lock do
    perform_backup
  end
end