FEATURE: new 'backup_time_of_day' site setting

This commit is contained in:
Régis Hanol 2015-11-12 16:14:49 +01:00
parent 16f509afb9
commit 72a7bd38e1
3 changed files with 11 additions and 2 deletions

View File

@ -1,7 +1,7 @@
module Jobs
class ScheduleBackup < Jobs::Scheduled
daily at: 3.hours
daily at: 0.hours
sidekiq_options retry: false
def execute(args)
@ -12,7 +12,12 @@ module Jobs
return if (date + SiteSetting.backup_frequency.days) > Time.now.to_date
end
Jobs.enqueue_in(rand(10.minutes), :create_backup)
Jobs.cancel_scheduled_job(:create_backup)
time_of_day = Time.parse(SiteSetting.backup_time_of_day)
seconds = time_of_day.hour.hours + time_of_day.min.minutes + rand(10.minutes)
Jobs.enqueue_in(seconds, :create_backup)
end
end
end

View File

@ -965,6 +965,7 @@ en:
backup_frequency: "How frequently we create a site backup, in days."
enable_s3_backups: "Upload backups to S3 when complete. IMPORTANT: requires valid S3 credentials entered in Files settings."
s3_backup_bucket: "The remote bucket to hold backups. WARNING: Make sure it is a private bucket."
backup_time_of_day: "Time of day when the backup should occur."
active_user_rate_limit_secs: "How frequently we update the 'last_seen_at' field, in seconds"
verbose_localization: "Show extended localization tips in the UI"

View File

@ -850,6 +850,9 @@ backups:
default: ''
regex: "^[^A-Z_.]+$" # can't use '.' when using HTTPS
shadowed_by_global: true
backup_time_of_day:
default: '3:30'
regex: "^((0?(0|1|2|3|4|5|6|7|8|9)|(10|11|12|13|14|15|16|17|18|19|20|21|22|23))):\\d\\d$"
uncategorized:
version_checks: