Class: Crowbar::Client::App::Backup

Inherits:
Base
  • Object
show all
Defined in:
lib/crowbar/client/app/backup.rb

Overview

A Thor based CLI wrapper for backup commands

Instance Method Summary collapse

Methods inherited from Base

banner, handle_argument_error, #initialize

Constructor Details

This class inherits a constructor from Crowbar::Client::App::Base

Instance Method Details

#create(name) ⇒ Object

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.

Parameters:

  • name (String)

    the name of the backup



145
146
147
148
149
150
151
152
153
# 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) ⇒ Object

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.

Parameters:

  • name (String)

    the name of the backup



172
173
174
175
176
177
178
179
180
# 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) ⇒ Object

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.

Parameters:

  • name (String)

    the name of the backup

  • file (String) (defaults to: nil)

    the path of the file



234
235
236
237
238
239
240
241
242
243
# 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

#listObject

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.



78
79
80
81
82
83
84
# 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) ⇒ Object

Backup restore command

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

Parameters:

  • name (String)

    the name of the backup



112
113
114
115
116
117
118
119
120
121
122
123
124
125
# 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) ⇒ Object

Backup upload command

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

Parameters:

  • file (String)

    the path to the file



198
199
200
201
202
203
204
205
206
# 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