Class: Pgchief::Command::DatabaseBackup
- Extended by:
- Forwardable
- Defined in:
- lib/pgchief/command/database_backup.rb
Overview
Command object to back up a database
Instance Attribute Summary collapse
-
#database ⇒ Object
readonly
Returns the value of attribute database.
Attributes inherited from Base
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(*params) ⇒ DatabaseBackup
constructor
A new instance of DatabaseBackup.
Methods inherited from Base
Constructor Details
#initialize(*params) ⇒ DatabaseBackup
15 16 17 18 19 |
# File 'lib/pgchief/command/database_backup.rb', line 15 def initialize(*params) super @database = params.first @uploader = Pgchief::Command::S3Upload.new(local_location) end |
Instance Attribute Details
#database ⇒ Object (readonly)
Returns the value of attribute database.
13 14 15 |
# File 'lib/pgchief/command/database_backup.rb', line 13 def database @database end |
Instance Method Details
#call ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/pgchief/command/database_backup.rb', line 21 def call raise Pgchief::Errors::DatabaseMissingError unless db_exists? backup! check_backup! upload! if configured? "Database '#{database}' backed up to #{location}" rescue PG::Error => e "Error: #{e.message}" ensure conn.close end |