Skip to content

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.rb
index cddb4e5cc6c..1bfd68e51ff 100644
--- a/app/jobs/scheduled/schedule_backup.rb
+++ b/app/jobs/scheduled/schedule_backup.rb
@@ -7,7 +7,8 @@ module Jobs
def 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.create
if latest_backup = store.latest_file
diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml
index 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.yml
index 8cdd83f2360..9f372ae9db6 100644
--- a/config/site_settings.yml
+++ b/config/site_settings.yml
@@ -3125,8 +3125,6 @@ backups:
remove_older_backups:
client: true
default: ""
- automatic_backups_enabled:
- default: true
backup_frequency:
min: 1
max: 30
diff --git a/db/post_migrate/20250710074447_clear_backup_frequency_if_disabled.rb b/db/post_migrate/20250710074447_clear_backup_frequency_if_disabled.rb
new file mode 100644
index 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
+end
diff --git a/script/bulk_import/vanilla.rb b/script/bulk_import/vanilla.rb
index 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 = 102400
diff --git a/script/bulk_import/vbulletin.rb b/script/bulk_import/vbulletin.rb
index c9eb374fab3..bfd430b0c3d 100644
--- a/script/bulk_import/vbulletin.rb
+++ b/script/bulk_import/vbulletin.rb
@@ -48,7 +48,7 @@ class BulkImport::VBulletin < BulkImport::Base
def 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 = 102400
diff --git a/script/bulk_import/vbulletin5.rb b/script/bulk_import/vbulletin5.rb
index 960fa4d3562..7a15fe6688d 100644
--- a/script/bulk_import/vbulletin5.rb
+++ b/script/bulk_import/vbulletin5.rb
@@ -58,7 +58,7 @@ class BulkImport::VBulletin5 < BulkImport::Base
def 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 = 102400
diff --git a/spec/lib/backup_restore/shared_examples_for_backup_store.rb b/spec/lib/backup_restore/shared_examples_for_backup_store.rb
index 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" do
expect(store.files).to eq([backup1])
end
- it "runs if SiteSetting.automatic_backups_enabled? is true" do
+ it "runs if SiteSetting.backup_frequency is configured" do
base_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 = 1
scheduleBackup = Jobs::ScheduleBackup.new
scheduleBackup.expects(:delete_prior_to_n_days)
scheduleBackup.perform