Class: Backy::CLI
- Inherits:
-
Thor
- Object
- Thor
- Backy::CLI
- Defined in:
- lib/backy/cli.rb
Instance Method Summary collapse
- #download ⇒ Object
- #dump ⇒ Object
-
#initialize(*args) ⇒ CLI
constructor
A new instance of CLI.
- #list ⇒ Object
- #push ⇒ Object
- #restore ⇒ Object
- #upload ⇒ Object
Constructor Details
#initialize(*args) ⇒ CLI
Returns a new instance of CLI.
6 7 8 9 10 |
# File 'lib/backy/cli.rb', line 6 def initialize(*args) Logger.log("Initializing Backy CLI...") super Backy.setup end |
Instance Method Details
#download ⇒ Object
37 38 39 40 41 42 |
# File 'lib/backy/cli.rb', line 37 def download file_name = [:file] validate_file!(file_name, should_exist: false) load_from_s3_if_missing(file_name) Logger.success("File downloaded from S3.") end |
#dump ⇒ Object
13 14 15 16 |
# File 'lib/backy/cli.rb', line 13 def dump Backy::PgDump.new.call Logger.success("Database dumped successfully.") end |
#list ⇒ Object
45 46 47 48 49 |
# File 'lib/backy/cli.rb', line 45 def list list = Backy::List.new.call list.each { |item| say "#{item.local? ? "local" : " "} #{item.remote? ? "remote" : " "} : #{item.dump_file}", :yellow } say_instructions_if_any(list) end |
#push ⇒ Object
19 20 21 22 23 24 |
# File 'lib/backy/cli.rb', line 19 def push file_name = Backy::PgDump.new.call save_to_s3(file_name) File.delete(file_name) if File.exist?(file_name) Logger.success("Dump pushed to S3 and local file deleted.") end |
#restore ⇒ Object
53 54 55 56 57 |
# File 'lib/backy/cli.rb', line 53 def restore file_name = find_file_for_restore([:file]) pg_restore(load_from_s3_if_missing(file_name)) if file_name Logger.success("Database restored from #{file_name}.") end |
#upload ⇒ Object
28 29 30 31 32 33 |
# File 'lib/backy/cli.rb', line 28 def upload file_name = [:file] validate_file!(file_name) save_to_s3(file_name) Logger.success("File uploaded to S3.") end |