A platform for community discussion. Free, open, simple.
DEV: Remove automatic_backups_enabled setting (#33558)
Ted Johanssonf8bf51441e71
diff --git a/app/jobs/scheduled/schedule_backup.rb b/app/jobs/scheduled/schedule_backup.rbindex cddb4e5cc6c..1bfd68e51ff 100644--- a/app/jobs/scheduled/schedule_backup.rb+++ b/app/jobs/scheduled/schedule_backup.rb@@ -7,7 +7,8 @@ module Jobsdef execute(args)delete_prior_to_n_days- return unless SiteSetting.enable_backups? && SiteSetting.automatic_backups_enabled?+ return if !SiteSetting.enable_backups?+ return if SiteSetting.backup_frequency.blank?store = BackupRestore::BackupStore.createif latest_backup = store.latest_filediff --git a/config/locales/server.en.yml b/config/locales/server.en.ymlindex 3ab1f611f6e..11cab854591 100644--- a/config/locales/server.en.yml+++ b/config/locales/server.en.yml@@ -2026,8 +2026,7 @@ en:allow_restore: "Allow restore, which can replace ALL site data! Leave disabled unless you plan to restore a backup"maximum_backups: "The maximum amount of backups to keep. Older backups are automatically deleted"remove_older_backups: "Remove backups older than the specified number of days. Leave blank to disable."- automatic_backups_enabled: "Run automatic backups as defined in backup frequency"- backup_frequency: "Specifies the interval, in days, at which automatic backups of the site are created. If set to 7, for example, a new backup will be generated every week. The activation of this setting is contingent upon `automatic_backups_enabled`."+ backup_frequency: "Specifies the interval, in days, at which automatic backups of the site are created. If set to 7, for example, a new backup will be generated every week. Leave blank to disable."s3_backup_bucket: "The remote bucket to hold backups. WARNING: Make sure it is a private bucket."s3_endpoint: "The endpoint can be modified to backup to an S3 compatible service like DigitalOcean Spaces or Minio. WARNING: Leave blank if using AWS S3."s3_configure_tombstone_policy: "Enable automatic deletion policy for tombstone uploads. IMPORTANT: If disabled, no space will be reclaimed after uploads are deleted."diff --git a/config/site_settings.yml b/config/site_settings.ymlindex 8cdd83f2360..9f372ae9db6 100644--- a/config/site_settings.yml+++ b/config/site_settings.yml@@ -3125,8 +3125,6 @@ backups:remove_older_backups:client: truedefault: ""- automatic_backups_enabled:- default: truebackup_frequency:min: 1max: 30diff --git a/db/post_migrate/20250710074447_clear_backup_frequency_if_disabled.rb b/db/post_migrate/20250710074447_clear_backup_frequency_if_disabled.rbnew file mode 100644index 00000000000..5a9c26fe6ab--- /dev/null+++ b/db/post_migrate/20250710074447_clear_backup_frequency_if_disabled.rb@@ -0,0 +1,27 @@+# frozen_string_literal: true++class ClearBackupFrequencyIfDisabled < ActiveRecord::Migration[7.2]+ def up+ execute <<~SQL+ INSERT INTO site_settings (name, data_type, value, created_at, updated_at)+ SELECT 'backup_frequency', 3, NULL, 'NOW()', 'NOW()'+ WHERE EXISTS (+ SELECT 1+ FROM site_settings+ WHERE name = 'automatic_backups_enabled'+ AND VALUE = 'f'+ LIMIT 1+ )+ ON CONFLICT (name) DO UPDATE SET value = NULL, updated_at = 'NOW()';+ SQL++ execute <<~SQL+ DELETE FROM site_settings+ WHERE name = 'automatic_backups_enabled';+ SQL+ end++ def down+ raise ActiveRecord::IrreversibleMigration+ end+enddiff --git a/script/bulk_import/vanilla.rb b/script/bulk_import/vanilla.rbindex e9c91a02551..07be4013205 100644--- a/script/bulk_import/vanilla.rb+++ b/script/bulk_import/vanilla.rb@@ -63,7 +63,7 @@ class BulkImport::Vanilla < BulkImport::Base# SiteSetting.port = 3000# SiteSetting.permalink_normalizations = "/discussion\/(\d+)\/.*/discussion/\1"- # SiteSetting.automatic_backups_enabled = false+ # SiteSetting.backup_frequency = nil# SiteSetting.disable_emails = "non-staff"# SiteSetting.authorized_extensions = '*'# SiteSetting.max_image_size_kb = 102400diff --git a/script/bulk_import/vbulletin.rb b/script/bulk_import/vbulletin.rbindex c9eb374fab3..bfd430b0c3d 100644--- a/script/bulk_import/vbulletin.rb+++ b/script/bulk_import/vbulletin.rb@@ -48,7 +48,7 @@ class BulkImport::VBulletin < BulkImport::Basedef execute# enable as per requirement:- # SiteSetting.automatic_backups_enabled = false+ # SiteSetting.backup_frequency = nil# SiteSetting.disable_emails = "non-staff"# SiteSetting.authorized_extensions = '*'# SiteSetting.max_image_size_kb = 102400diff --git a/script/bulk_import/vbulletin5.rb b/script/bulk_import/vbulletin5.rbindex 960fa4d3562..7a15fe6688d 100644--- a/script/bulk_import/vbulletin5.rb+++ b/script/bulk_import/vbulletin5.rb@@ -58,7 +58,7 @@ class BulkImport::VBulletin5 < BulkImport::Basedef execute# enable as per requirement:- #SiteSetting.automatic_backups_enabled = false+ #SiteSetting.backup_frequency = nil#SiteSetting.disable_emails = "non-staff"#SiteSetting.authorized_extensions = '*'#SiteSetting.max_image_size_kb = 102400diff --git a/spec/lib/backup_restore/shared_examples_for_backup_store.rb b/spec/lib/backup_restore/shared_examples_for_backup_store.rbindex 39f6c11eb3f..84429add956 100644--- a/spec/lib/backup_restore/shared_examples_for_backup_store.rb+++ b/spec/lib/backup_restore/shared_examples_for_backup_store.rb@@ -170,7 +170,7 @@ RSpec.shared_examples "backup store" doexpect(store.files).to eq([backup1])end- it "runs if SiteSetting.automatic_backups_enabled? is true" do+ it "runs if SiteSetting.backup_frequency is configured" dobase_backup_s3_url = "https://s3-backup-bucket.s3.dualstack.us-west-1.amazonaws.com"stub_request(:get, "#{base_backup_s3_url}/?list-type=2&prefix=default/").to_return(status: 200,@@ -180,7 +180,7 @@ RSpec.shared_examples "backup store" do)stub_request(:head, "#{base_backup_s3_url}/").to_return(status: 200, body: "", headers: {})- SiteSetting.automatic_backups_enabled = true+ SiteSetting.backup_frequency = 1scheduleBackup = Jobs::ScheduleBackup.newscheduleBackup.expects(:delete_prior_to_n_days)scheduleBackup.perform