Class: Wordmove::Actions::Ssh::BackupRemoteDb

Inherits:
Object
  • Object
show all
Extended by:
LightService::Action
Includes:
Helpers
Defined in:
lib/wordmove/actions/ssh/backup_remote_db.rb

Overview

Bakups an alrady downloaded remote dump

Class Method Summary collapse

Class Method Details

.executeLightService::Context

Returns Action’s context.

Parameters:

  • cli_options (Hash)

    Command line options (with symbolized keys)

  • logger (Wordmove::Logger)
  • db_paths (BbPathsConfig)

    Configuration object for database

Returns:

  • (LightService::Context)

    Action’s context



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/wordmove/actions/ssh/backup_remote_db.rb', line 19

executed do |context|
  context.logger.task 'Backup remote DB'

  if simulate?(cli_options: context.cli_options)
    context.logger.info 'A backup of the remote DB would have been saved into ' \
                        "#{context.db_paths.backup.remote.gzipped_path}, " \
                        'but you\'re simulating'
    next context
  end

  # Most of the expectations are needed to be proxied to `DownloadRemoteDb`
  # Wordmove::Actions::Ssh::DownloadRemoteDb.execute(context)
  # DownloadRemoteDB will save the file in `db_paths.local.gzipped_path`

  begin
    FileUtils.mv(
      context.db_paths.local.gzipped_path,
      context.db_paths.backup.remote.gzipped_path
    )

    context.logger.success(
      "Backup saved at #{context.db_paths.backup.remote.gzipped_path}"
    )
  rescue Errno::ENOENT => e
    context.fail_and_return!("Remote DB backup failed with: #{e.message}. Aborting.")
  end
end