diff options
author | Stefan Wintermeyer <stefan.wintermeyer@amooma.de> | 2013-02-07 09:27:43 +0100 |
---|---|---|
committer | Stefan Wintermeyer <stefan.wintermeyer@amooma.de> | 2013-02-07 09:27:43 +0100 |
commit | 72f100c680ddcf9c36448ae3ee367eab19052adc (patch) | |
tree | 604f4bc303fcb71277fd17bafebed1aa573f4a75 /app | |
parent | 5685009f9fd60012034c1fde95d696225389a477 (diff) |
Use CarrierWave to store the tar.gz. Removed size_of_the_backup attribute.
Diffstat (limited to 'app')
-rw-r--r-- | app/models/backup_job.rb | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/app/models/backup_job.rb b/app/models/backup_job.rb index c1f12e4..78d95a7 100644 --- a/app/models/backup_job.rb +++ b/app/models/backup_job.rb @@ -5,7 +5,6 @@ class BackupJob < ActiveRecord::Base before_create :set_state_to_queued after_create :initiate_backup - after_destroy :delete_the_backup_directory private def set_state_to_queued @@ -29,14 +28,14 @@ class BackupJob < ActiveRecord::Base if tmp_backup_directory.blank? self.state = 'failed' else - system "cd #{backup_directory} && tar czf #{backup_name_prefix}#{tmp_backup_directory}.tar.gz #{tmp_backup_directory}" + system "cd #{backup_directory} && tar czf #{backup_name_prefix}#{File.basename(tmp_backup_directory)}.tar.gz #{File.basename(tmp_backup_directory)}" require 'fileutils' FileUtils.rm_rf tmp_backup_directory - file = File::Stat.new("#{backup_directory}/#{backup_name_prefix}#{tmp_backup_directory}.tar.gz") + file = File::Stat.new("#{backup_directory}/#{backup_name_prefix}#{File.basename(tmp_backup_directory)}.tar.gz") - self.size_of_the_backup = file.size + self.directory = File.basename(tmp_backup_directory) - self.backup_file = File.open("#{backup_directory}/#{backup_name_prefix}#{tmp_backup_directory}.tar.gz") + self.backup_file = File.open("#{backup_directory}/#{backup_name_prefix}#{File.basename(tmp_backup_directory)}.tar.gz") self.finished_at = Time.now self.state = 'successful' @@ -45,10 +44,4 @@ class BackupJob < ActiveRecord::Base end end - def delete_the_backup_directory - # if !tmp_backup_directory.blank? - # require 'fileutils' - # FileUtils.rm_rf tmp_backup_directory - # end - end end |