diff options
-rw-r--r-- | app/models/backup_job.rb | 15 | ||||
-rw-r--r-- | db/migrate/20130207082728_remove_size_of_the_backup_from_backup_job.rb | 9 |
2 files changed, 13 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 diff --git a/db/migrate/20130207082728_remove_size_of_the_backup_from_backup_job.rb b/db/migrate/20130207082728_remove_size_of_the_backup_from_backup_job.rb new file mode 100644 index 0000000..a902fd2 --- /dev/null +++ b/db/migrate/20130207082728_remove_size_of_the_backup_from_backup_job.rb @@ -0,0 +1,9 @@ +class RemoveSizeOfTheBackupFromBackupJob < ActiveRecord::Migration + def up + remove_column :backup_jobs, :size_of_the_backup + end + + def down + add_column :backup_jobs, :size_of_the_backup, :string + end +end |