mirror of
https://github.com/codeninjasllc/discourse.git
synced 2025-02-17 04:01:29 -05:00
FEATURE: New site setting to enable a daily automatic backup
This commit is contained in:
parent
9ca516e58d
commit
42ca83ece5
4 changed files with 36 additions and 0 deletions
14
app/jobs/scheduled/create_backup.rb
Normal file
14
app/jobs/scheduled/create_backup.rb
Normal file
|
@ -0,0 +1,14 @@
|
|||
require_dependency "backup_restore"
|
||||
|
||||
module Jobs
|
||||
class CreateBackup < Jobs::Scheduled
|
||||
every 1.day
|
||||
sidekiq_options retry: false
|
||||
|
||||
def execute(args)
|
||||
return unless SiteSetting.backup_daily?
|
||||
BackupRestore.backup!(Discourse.system_user.id, false)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -713,6 +713,7 @@ en:
|
|||
|
||||
allow_restore: "Allow restore, which can replace ALL site data! Leave false unless you plan to do restore a backup"
|
||||
maximum_backups: "The maximum amount of backups to keep on disk. Older backups are automatically deleted"
|
||||
backup_daily: "Automatically create a site backup once a day"
|
||||
|
||||
active_user_rate_limit_secs: "How frequently we update the 'last_seen_at' field, in seconds"
|
||||
previous_visit_timeout_hours: "How long a visit lasts before we consider it the 'previous' visit, in hours"
|
||||
|
|
|
@ -416,6 +416,9 @@ backups:
|
|||
maximum_backups:
|
||||
client: true
|
||||
default: 7
|
||||
backup_daily:
|
||||
client: false
|
||||
default: false
|
||||
|
||||
uncategorized:
|
||||
|
||||
|
|
18
spec/jobs/create_backup_spec.rb
Normal file
18
spec/jobs/create_backup_spec.rb
Normal file
|
@ -0,0 +1,18 @@
|
|||
require 'spec_helper'
|
||||
|
||||
require_dependency 'jobs/scheduled/create_backup'
|
||||
|
||||
describe Jobs::CreateBackup do
|
||||
it "does nothing when daily backups are disabled" do
|
||||
SiteSetting.stubs(:backup_daily?).returns(false)
|
||||
BackupRestore.expects(:backup!).never
|
||||
Jobs::CreateBackup.new.execute({})
|
||||
end
|
||||
|
||||
it "calls `backup!` when the daily backups are enabled" do
|
||||
SiteSetting.stubs(:backup_daily?).returns(true)
|
||||
BackupRestore.expects(:backup!).with(Discourse.system_user.id, false).once
|
||||
Jobs::CreateBackup.new.execute({})
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in a new issue