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

@ -6,12 +6,13 @@ module BackupRestore
delegate :log, to: :@logger, private: true
def initialize(logger, filename, current_db, root_tmp_directory = Rails.root)
def initialize(logger, filename, current_db, root_tmp_directory = Rails.root, location = nil)
@logger = logger
@filename = filename
@current_db = current_db
@root_tmp_directory = root_tmp_directory
@is_archive = !(@filename =~ /\.sql\.gz$/)
@store_location = location
end
def decompress
@ -48,7 +49,7 @@ module BackupRestore
end
def copy_archive_to_tmp_directory
store = BackupRestore::BackupStore.create
store = BackupRestore::BackupStore.create(location: @store_location)
if store.remote?
log "Downloading archive to tmp directory..."