Class: Bosh::Director::Jobs::Backup

Inherits:
BaseJob show all
Defined in:
lib/bosh/director/jobs/backup.rb

Instance Attribute Summary collapse

Attributes inherited from BaseJob

#task_id

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseJob

#begin_stage, #dns_manager, #event_manager, #logger, perform, #result_file, schedule_message, #single_step_stage, #task_cancelled?, #task_checkpoint, #track_and_log, #username

Constructor Details

#initialize(dest, options = {}) ⇒ Backup

Returns a new instance of Backup.



14
15
16
17
18
# File 'lib/bosh/director/jobs/backup.rb', line 14

def initialize(dest, options={})
  @backup_file = dest
  @tar_gzipper = options.fetch(:tar_gzipper) { Core::TarGzipper.new }
  @db_adapter = options.fetch(:db_adapter) { Bosh::Director::DbBackup.create(Config.db_config) }
end

Instance Attribute Details

#backup_fileObject (readonly)

Returns the value of attribute backup_file.



12
13
14
# File 'lib/bosh/director/jobs/backup.rb', line 12

def backup_file
  @backup_file
end

Class Method Details

.job_typeObject



8
9
10
# File 'lib/bosh/director/jobs/backup.rb', line 8

def self.job_type
  :bosh_backup
end

Instance Method Details

#performObject



20
21
22
23
24
25
26
27
# File 'lib/bosh/director/jobs/backup.rb', line 20

def perform
  Dir.mktmpdir do |tmp_output_dir|
    begin_stage('Backing up director', 4)
    backup_database("#{tmp_output_dir}/director_db.sql")
    @tar_gzipper.compress(tmp_output_dir, 'director_db.sql', @backup_file)
    "Backup created at #{@backup_file}"
  end
end