mirror of
https://github.com/discourse/discourse.git
synced 2026-09-05 04:40:41 -05:00
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:
@@ -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..."
|
||||
|
||||
@@ -8,7 +8,7 @@ module BackupRestore
|
||||
|
||||
# @return [BackupStore]
|
||||
def self.create(opts = {})
|
||||
case SiteSetting.backup_location
|
||||
case opts[:location] || SiteSetting.backup_location
|
||||
when BackupLocationSiteSetting::LOCAL
|
||||
require_dependency "backup_restore/local_backup_store"
|
||||
BackupRestore::LocalBackupStore.new(opts)
|
||||
|
||||
@@ -27,8 +27,8 @@ module BackupRestore
|
||||
MetaDataHandler.new(logger, filename, tmp_directory)
|
||||
end
|
||||
|
||||
def create_backup_file_handler(filename, current_db)
|
||||
BackupFileHandler.new(logger, filename, current_db)
|
||||
def create_backup_file_handler(filename, current_db, location)
|
||||
BackupFileHandler.new(logger, filename, current_db, location)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -9,7 +9,7 @@ module BackupRestore
|
||||
|
||||
attr_reader :success
|
||||
|
||||
def initialize(user_id:, filename:, factory:, disable_emails: true)
|
||||
def initialize(user_id:, filename:, factory:, disable_emails: true, location:)
|
||||
@user_id = user_id
|
||||
@filename = filename
|
||||
@factory = factory
|
||||
@@ -24,7 +24,7 @@ module BackupRestore
|
||||
@current_db = RailsMultisite::ConnectionManagement.current_db
|
||||
|
||||
@system = factory.create_system_interface
|
||||
@backup_file_handler = factory.create_backup_file_handler(@filename, @current_db)
|
||||
@backup_file_handler = factory.create_backup_file_handler(@filename, @current_db, location)
|
||||
@database_restorer = factory.create_database_restorer(@current_db)
|
||||
@uploads_restorer = factory.create_uploads_restorer
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user