class Crowbar::Client::App::Backup

A Thor based CLI wrapper for backup commands

Public Instance Methods

accepts_restore?() click to toggle source

Ask if the restore should be really down

@return [Bool] allow or disallow a restore

# File lib/crowbar/client/app/backup.rb, line 251
          def accepts_restore?
            return true if options[:yes]

            question = <<-QUESTION.strip_heredoc
              Usage of this command is dangerous as it overwrites the
              current state of the server and the proposals. Are you
              sure you want to proceed?
            QUESTION

            answer = ask(
              question,
              :red,
              limited_to: [
                "yes",
                "no"
              ]
            )

            answer == "yes"
          end
create(name) click to toggle source

Backup create command

It will trigger the creation of a new backup on the server, to download the backup after processing you can use the download command.

@param name [String] the name of the backup

# File lib/crowbar/client/app/backup.rb, line 145
def create(name)
  Command::Backup::Create.new(
    *command_params(
      name: name
    )
  ).execute
rescue => e
  catch_errors(e)
end
delete(name) click to toggle source

Backup delete command

It will delete a backup from the server. Be careful with that command, you are not able to restore this file after deletion.

@param name [String] the name of the backup

# File lib/crowbar/client/app/backup.rb, line 172
def delete(name)
  Command::Backup::Delete.new(
    *command_params(
      name: name
    )
  ).execute
rescue => e
  catch_errors(e)
end
download(name, file = nil) click to toggle source

Backup download command

It will download a backup from the server. If you specify a `file` the download gets written to that file, otherwise it gets saved to the current working directory with an automatically generated filename. You can directly provide a path to a file or just pipe the content to stdout. To pipe the content to stdout you should just write a `-` instead of a specific filename.

@param name [String] the name of the backup @param file [String] the path of the file

# File lib/crowbar/client/app/backup.rb, line 234
def download(name, file = nil)
  Command::Backup::Download.new(
    *command_params(
      name: name,
      file: file
    )
  ).execute
rescue => e
  catch_errors(e)
end
list() click to toggle source

Backup list command

It will print out a list of existing backups on the server. You can display the list in different output formats and you can filter the list by any search criteria.

# File lib/crowbar/client/app/backup.rb, line 78
def list
  Command::Backup::List.new(
    *command_params
  ).execute
rescue => e
  catch_errors(e)
end
restore(name) click to toggle source

Backup restore command

It will trigger the restore process based on the specified backup name. This command will override the proposals of your server.

@param name [String] the name of the backup

# File lib/crowbar/client/app/backup.rb, line 112
def restore(name)
  unless accepts_restore?
    say "Canceled restore"
    return
  end

  Command::Backup::Restore.new(
    *command_params(
      name: name
    )
  ).execute
rescue => e
  catch_errors(e)
end
upload(file) click to toggle source

Backup upload command

It will upload a backup to the server. You can use this backup later to trigger a restore.

@param file [String] the path to the file

# File lib/crowbar/client/app/backup.rb, line 198
def upload(file)
  Command::Backup::Upload.new(
    *command_params(
      file: file
    )
  ).execute
rescue => e
  catch_errors(e)
end