summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
Diffstat (limited to 'app/models')
-rw-r--r--app/models/backup_job.rb2
-rw-r--r--app/models/restore_job.rb13
2 files changed, 13 insertions, 2 deletions
diff --git a/app/models/backup_job.rb b/app/models/backup_job.rb
index 96574a7..a04f6c0 100644
--- a/app/models/backup_job.rb
+++ b/app/models/backup_job.rb
@@ -32,7 +32,7 @@ class BackupJob < ActiveRecord::Base
if tmp_backup_directory.blank?
self.state = 'failed'
else
- system "cd #{backup_directory} && tar czf #{backup_name_prefix}#{File.basename(tmp_backup_directory)}.tar.gz #{File.basename(tmp_backup_directory)}"
+ system "cd #{backup_directory} && sudo /bin/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}#{File.basename(tmp_backup_directory)}.tar.gz")
diff --git a/app/models/restore_job.rb b/app/models/restore_job.rb
index 2c2da54..80741ac 100644
--- a/app/models/restore_job.rb
+++ b/app/models/restore_job.rb
@@ -3,11 +3,22 @@ class RestoreJob < ActiveRecord::Base
mount_uploader :backup_file, BackupFileUploader
+ after_create :queue_the_restore_rake_task
+
def to_s
if self.backup_file?
File.basename(self.backup_file.to_s)
else
"RestoreJob ID #{self.id}"
end
- end
+ end
+
+ private
+ def queue_the_restore_rake_task
+ self.delay.run_the_restore_rake_task
+ end
+
+ def run_the_restore_rake_task
+ system "cd #{Rails.root} && rake backup:restore"
+ end
end