Class: BackupRestore::Backuper
- Inherits:
-
Object
- Object
- BackupRestore::Backuper
- Defined in:
- lib/backup_restore/backuper.rb
Instance Attribute Summary collapse
-
#store ⇒ Object
readonly
Returns the value of attribute store.
-
#success ⇒ Object
readonly
Returns the value of attribute success.
Instance Method Summary collapse
-
#initialize(user_id, opts = {}) ⇒ Backuper
constructor
A new instance of Backuper.
- #run ⇒ Object
Constructor Details
#initialize(user_id, opts = {}) ⇒ Backuper
Returns a new instance of Backuper.
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/backup_restore/backuper.rb', line 10 def initialize(user_id, opts = {}) @user_id = user_id @client_id = opts[:client_id] @publish_to_message_bus = opts[:publish_to_message_bus] || false @with_uploads = opts[:with_uploads] == false ? false : include_uploads? @filename_override = opts[:filename] @ticket = opts[:ticket] initialize_state end |
Instance Attribute Details
#store ⇒ Object (readonly)
Returns the value of attribute store.
8 9 10 |
# File 'lib/backup_restore/backuper.rb', line 8 def store @store end |
#success ⇒ Object (readonly)
Returns the value of attribute success.
8 9 10 |
# File 'lib/backup_restore/backuper.rb', line 8 def success @success end |
Instance Method Details
#run ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/backup_restore/backuper.rb', line 21 def run ensure_no_operation_is_running ensure_we_have_a_user log "[STARTED]" log "'#{@user.username}' has started the backup!" mark_backup_as_running listen_for_shutdown_signal ensure_directory_exists(@tmp_directory) ensure_directory_exists(@archive_directory) dump_public_schema log "Finalizing backup..." @with_uploads ? create_archive : move_dump_backup upload_archive after_create_hook rescue SystemExit log "Backup process was cancelled!" rescue Exception => ex log "EXCEPTION: " + ex. log ex.backtrace.join("\n") else @success = true @backup_filename ensure delete_old clean_up notify_user log "Finished!" publish_completion end |