2015-03-26 02:21:27 -04:00
|
|
|
|
|
|
|
module Jobs
|
|
|
|
class ScheduleBackup < Jobs::Scheduled
|
|
|
|
daily at: 3.hours
|
|
|
|
sidekiq_options retry: false
|
|
|
|
|
|
|
|
def execute(args)
|
2015-08-14 02:25:29 -04:00
|
|
|
return unless SiteSetting.automatic_backups_enabled?
|
2015-08-07 11:34:58 -04:00
|
|
|
|
|
|
|
if latest_backup = Backup.all[0]
|
2015-08-14 02:25:29 -04:00
|
|
|
date = File.ctime(latest_backup.path).to_date
|
|
|
|
return if (date + SiteSetting.backup_frequency.days) > Time.now.to_date
|
2015-08-07 11:34:58 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
Jobs.enqueue_in(rand(10.minutes), :create_backup)
|
2015-03-26 02:21:27 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|