FEATURE: Allow overriding the backup location when restoring via CLI (#12015)

You can use `discourse restore --location=local FILENAME` if you want to restore a backup that is stored locally even though the `backup_location` has the value `s3`.
This commit is contained in:
Gerhard Schlager
2021-02-09 16:02:44 +01:00
committed by GitHub
parent b3fa521bf4
commit 4d719725c8
6 changed files with 28 additions and 10 deletions

View File

@ -7,7 +7,8 @@ describe BackupRestore::BackupFileHandler do
include_context "shared stuff"
def expect_decompress_and_clean_up_to_work(backup_filename:, expected_dump_filename: "dump.sql",
require_metadata_file:, require_uploads:, expected_upload_paths: nil)
require_metadata_file:, require_uploads:, expected_upload_paths: nil,
location: nil)
freeze_time(DateTime.parse('2019-12-24 14:31:48'))
@ -18,7 +19,7 @@ describe BackupRestore::BackupFileHandler do
Dir.mktmpdir do |root_directory|
current_db = RailsMultisite::ConnectionManagement.current_db
file_handler = BackupRestore::BackupFileHandler.new(logger, backup_filename, current_db, root_directory)
file_handler = BackupRestore::BackupFileHandler.new(logger, backup_filename, current_db, root_directory, location)
tmp_directory, db_dump_path = file_handler.decompress
expected_tmp_path = File.join(root_directory, "tmp/restores", current_db, "2019-12-24-143148")
@ -101,4 +102,18 @@ describe BackupRestore::BackupFileHandler do
end
end
end
it "allows overriding the backup store" do
SiteSetting.s3_backup_bucket = "s3-backup-bucket"
SiteSetting.s3_access_key_id = "s3-access-key-id"
SiteSetting.s3_secret_access_key = "s3-secret-access-key"
SiteSetting.backup_location = BackupLocationSiteSetting::S3
expect_decompress_and_clean_up_to_work(
backup_filename: "backup_since_v1.6.tar.gz",
require_metadata_file: false,
require_uploads: true,
location: BackupLocationSiteSetting::LOCAL
)
end
end