Class: Bosh::Director::Jobs::Backup
- Defined in:
- lib/bosh/director/jobs/backup.rb
Instance Attribute Summary collapse
-
#backup_file ⇒ Object
readonly
Returns the value of attribute backup_file.
Attributes inherited from BaseJob
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(dest, options = {}) ⇒ Backup
constructor
A new instance of Backup.
- #perform ⇒ Object
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(dest, options = {}) ⇒ Backup
Returns a new instance of Backup.
14 15 16 17 18 19 20 21 |
# File 'lib/bosh/director/jobs/backup.rb', line 14 def initialize(dest, ={}) @backup_file = dest @tar_gzipper = .fetch(:tar_gzipper) { Core::TarGzipper.new } @blobstore_client = .fetch(:blobstore) { App.instance.blobstores.blobstore } @db_adapter = .fetch(:db_adapter) { Bosh::Director::DbBackup.create(Config.db_config) } @base_dir = .fetch(:base_dir) { Config.base_dir } @log_dir = .fetch(:log_dir) { Config.log_dir } end |
Instance Attribute Details
#backup_file ⇒ Object (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_type ⇒ Object
8 9 10 |
# File 'lib/bosh/director/jobs/backup.rb', line 8 def self.job_type :bosh_backup end |
Instance Method Details
#perform ⇒ Object
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 |
# File 'lib/bosh/director/jobs/backup.rb', line 23 def perform Dir.mktmpdir do |tmp_output_dir| event_log.begin_stage('Backing up director', 4) files = [] if @log_dir backup_logs("#{tmp_output_dir}/logs.tgz") files << 'logs.tgz' end backup_task_logs("#{tmp_output_dir}/task_logs.tgz") files << 'task_logs.tgz' backup_database("#{tmp_output_dir}/director_db.sql") files << 'director_db.sql' backup_blobstore("#{tmp_output_dir}/blobs.tgz") files << 'blobs.tgz' @tar_gzipper.compress(tmp_output_dir, files, @backup_file) "Backup created at #{@backup_file}" end end |