Class: Bosh::Director::Jobs::ScheduledBackup

Inherits:
BaseJob show all
Defined in:
lib/bosh/director/jobs/scheduled_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, #event_log, #logger, perform, #result_file, #single_step_stage, #task_cancelled?, #task_checkpoint, #track_and_log

Constructor Details

#initialize(options = {}) ⇒ ScheduledBackup

Returns a new instance of ScheduledBackup.



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

def initialize(options={})
  @backup_job = options.fetch(:backup_job) { Backup.new(backup_file) }
  @backup_destination = options.fetch(:backup_destination) { App.instance.blobstores.backup_destination }
end

Instance Attribute Details

#backup_jobObject (readonly)

Returns the value of attribute backup_job.



6
7
8
# File 'lib/bosh/director/jobs/scheduled_backup.rb', line 6

def backup_job
  @backup_job
end

Class Method Details

.job_typeObject



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

def self.job_type
  :scheduled_backup
end

Instance Method Details

#performObject



17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/bosh/director/jobs/scheduled_backup.rb', line 17

def perform
  @backup_job.perform

  blobstore_path = "backup-#{Time.now.utc.iso8601}.tgz"

  File.open(@backup_job.backup_file) do |f|
    @backup_destination.create(f, blobstore_path)
  end

  "Stored `#{blobstore_path}' in backup blobstore"
ensure
  FileUtils.rm_f(@backup_job.backup_file)
end