mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-12-04 21:01:27 -05:00
e670ebb433
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
18 lines
450 B
Ruby
18 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
|