discourse/app/jobs/scheduled/schedule_backup.rb
Sam e670ebb433 FEATURE: allow backup settings to be overriden by globals
FEATURE: allow backup interval of up to 30 days
FIX: if a custom file exists in backup directory look at its date
FEATURE: site setting automatic_backups_enabled default true
2015-08-14 16:28:29 +10:00

19 lines
450 B
Ruby

module Jobs
class ScheduleBackup < Jobs::Scheduled
daily at: 3.hours
sidekiq_options retry: false
def execute(args)
return unless SiteSetting.automatic_backups_enabled?
if latest_backup = Backup.all[0]
date = File.ctime(latest_backup.path).to_date
return if (date + SiteSetting.backup_frequency.days) > Time.now.to_date
end
Jobs.enqueue_in(rand(10.minutes), :create_backup)
end
end
end