Class: KamalBackup::CLI::DrillCLI

Inherits:
CommandBase show all
Defined in:
lib/kamal_backup/cli.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Helpers

#accessory_name, #accessory_reboot_command, #bridge, #command_env, #confirm!, #default_deploy_config?, #deploy_snippet, #deployment_mode?, #direct_app, #ensure_remote_version_match!, #exec_remote, #init_config_root, #local_app, #local_command_config, #local_preferences, #print_remote_version_status, #prompt_required, #redactor, #remote_version, #shared_config_path, #shared_config_template, #version_remote_mode?, #write_init_file

Class Method Details

.basenameObject



217
218
219
# File 'lib/kamal_backup/cli.rb', line 217

def self.basename
  CLI.basename
end

Instance Method Details

#local(snapshot = "latest") ⇒ Object



223
224
225
226
227
228
# File 'lib/kamal_backup/cli.rb', line 223

def local(snapshot = "latest")
  confirm!("Run a local restore drill for #{snapshot}? This will overwrite local data.")
  result = local_app.drill_on_local_machine(snapshot, check_command: options[:check])
  puts(JSON.pretty_generate(result))
  exit(1) if local_app.drill_failed?(result)
end

#production(snapshot = "latest") ⇒ Object



235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
# File 'lib/kamal_backup/cli.rb', line 235

def production(snapshot = "latest")
  confirm!("Run a production-side restore drill for #{snapshot}? This will restore into scratch targets on production infrastructure.")

  if deployment_mode?
    argv = ["kamal-backup", "drill", "production", snapshot, "--files", options[:files], "--yes"]
    argv.concat(["--database", production_database_name]) if production_database_name
    argv.concat(["--sqlite-path", options[:"sqlite-path"]]) if options[:"sqlite-path"]
    argv.concat(["--check", options[:check]]) if options[:check]
    exec_remote(argv)
  else
    result = direct_app.drill_on_production(
      snapshot,
      database_name: production_database_name,
      sqlite_path: options[:"sqlite-path"],
      file_target: options[:files],
      check_command: options[:check]
    )
    puts(JSON.pretty_generate(result))
    exit(1) if direct_app.drill_failed?(result)
  end
end