Class: Bard::CLI::BackupCommands

Inherits:
Thor
  • Object
show all
Defined in:
lib/bard/plugins/backup_restore.rb

Instance Method Summary collapse

Instance Method Details

#restore(timestamp = nil) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/bard/plugins/backup_restore.rb', line 16

def restore(timestamp = nil)
  if timestamp.nil?
    Bard::Command.run! "bin/rake bard:backup:restore", verbose: true
  else
    say "This will DROP and reload your LOCAL database from the backup nearest #{timestamp}.", :yellow
    unless yes?("Continue? (y/N)")
      say "Aborted."
      exit 1
    end
    Bard::Command.run! %(bin/rake "bard:backup:restore[#{timestamp}]"), verbose: true
  end
rescue Bard::Command::Error => e
  say "!!! Running command failed: #{e.message}", :red
  exit 1
end