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
This commit is contained in:
Sam 2015-08-14 16:25:29 +10:00
parent 07e66a5eff
commit e670ebb433
5 changed files with 12 additions and 9 deletions

View File

@ -5,7 +5,6 @@ module Jobs
sidekiq_options retry: false
def execute(args)
return unless SiteSetting.backups_enabled?
BackupRestore.backup!(Discourse.system_user.id, publish_to_message_bus: false)
end
end

View File

@ -5,11 +5,11 @@ module Jobs
sidekiq_options retry: false
def execute(args)
return unless SiteSetting.backups_enabled?
return unless SiteSetting.automatic_backups_enabled?
if latest_backup = Backup.all[0]
date = Date.parse(latest_backup.filename[/\d{4}-\d{2}-\d{2}/])
return if date + SiteSetting.backup_frequency.days > Time.now
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)

View File

@ -113,10 +113,6 @@ class SiteSetting < ActiveRecord::Base
false
end
def self.backups_enabled?
SiteSetting.backup_frequency > 0
end
end
# == Schema Information

View File

@ -938,6 +938,7 @@ en:
allow_restore: "Allow restore, which can replace ALL site data! Leave false unless you plan to restore a backup"
maximum_backups: "The maximum amount of backups to keep on disk. Older backups are automatically deleted"
automatic_backups_enabled: "Run automatic backups as defined in backup frequency"
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."

View File

@ -791,15 +791,22 @@ backups:
maximum_backups:
client: true
default: 7
shadowed_by_global: true
automatic_backups_enabled:
default: true
shadowed_by_global: true
backup_frequency:
min: 0
min: 1
max: 30
default: 7
shadowed_by_global: true
enable_s3_backups:
default: false
shadowed_by_global: true
s3_backup_bucket:
default: ''
regex: "^[^A-Z_.]+$" # can't use '.' when using HTTPS
shadowed_by_global: true
uncategorized:
version_checks: