FEATURE: Allow Forums to disable the Backups feature
This commit is contained in:
parent
9a514e6a26
commit
69a90f31fb
|
@ -68,7 +68,7 @@ export default Discourse.Route.extend({
|
|||
function(confirmed) {
|
||||
if (confirmed) {
|
||||
backup.destroy().then(function() {
|
||||
self.controllerFor("adminBackupsIndex").removeObject(backup);
|
||||
self.controllerFor("adminBackupsIndex").get('model').removeObject(backup);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,9 @@
|
|||
{{#if currentUser.admin}}
|
||||
{{nav-item route='adminCustomize' label='admin.customize.title'}}
|
||||
{{nav-item route='adminApi' label='admin.api.title'}}
|
||||
{{nav-item route='admin.backups' label='admin.backups.title'}}
|
||||
{{#if siteSettings.enable_backups}}
|
||||
{{nav-item route='admin.backups' label='admin.backups.title'}}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
{{nav-item route='adminPlugins' label='admin.plugins.title'}}
|
||||
{{plugin-outlet name="admin-menu" connectorTagName="li"}}
|
||||
|
|
|
@ -2,6 +2,7 @@ require "backup_restore/backup_restore"
|
|||
|
||||
class Admin::BackupsController < Admin::AdminController
|
||||
|
||||
before_action :ensure_backups_enabled
|
||||
skip_before_action :check_xhr, only: [:index, :show, :logs, :check_backup_chunk, :upload_backup_chunk]
|
||||
|
||||
def index
|
||||
|
@ -178,4 +179,8 @@ class Admin::BackupsController < Admin::AdminController
|
|||
`df -Pk #{Rails.root}/public/backups | awk 'NR==2 {print $4 * 1024;}'`.to_i > size
|
||||
end
|
||||
|
||||
def ensure_backups_enabled
|
||||
raise Discourse::InvalidAccess.new unless SiteSetting.enable_backups?
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -5,7 +5,7 @@ module Jobs
|
|||
sidekiq_options retry: false
|
||||
|
||||
def execute(args)
|
||||
return unless SiteSetting.automatic_backups_enabled?
|
||||
return unless SiteSetting.enable_backups? && SiteSetting.automatic_backups_enabled?
|
||||
|
||||
if latest_backup = Backup.all[0]
|
||||
date = File.ctime(latest_backup.path).getutc.to_date
|
||||
|
|
|
@ -1159,6 +1159,7 @@ en:
|
|||
github_client_secret: "Client secret for Github authentication, registered at https://github.com/settings/applications"
|
||||
|
||||
readonly_mode_during_backup: "Enable read only mode while taking a backup"
|
||||
enable_backups: "Allow administrators to create backups of the forum"
|
||||
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"
|
||||
|
|
|
@ -1168,6 +1168,10 @@ legal:
|
|||
default: ''
|
||||
|
||||
backups:
|
||||
enable_backups:
|
||||
default: true
|
||||
shadowed_by_global: true
|
||||
client: true
|
||||
readonly_mode_during_backup:
|
||||
default: false
|
||||
allow_restore:
|
||||
|
|
|
@ -7,6 +7,14 @@ RSpec.describe Admin::BackupsController do
|
|||
sign_in(admin)
|
||||
end
|
||||
|
||||
describe "#index" do
|
||||
it "raises an error when backups are disabled" do
|
||||
SiteSetting.enable_backups = false
|
||||
get "/admin/backups.json"
|
||||
expect(response).not_to be_success
|
||||
end
|
||||
end
|
||||
|
||||
describe '#rollback' do
|
||||
it 'should rollback the restore' do
|
||||
BackupRestore.expects(:rollback!)
|
||||
|
|
Loading…
Reference in New Issue