2
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2025-09-05 08:59:27 +08: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:
Gerhard Schlager 2021-02-09 16:02:44 +01:00 committed by GitHub
parent b3fa521bf4
commit 4d719725c8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 28 additions and 10 deletions

View file

@ -108,6 +108,7 @@ class DiscourseCLI < Thor
desc "restore", "Restore a Discourse backup"
option :disable_emails, type: :boolean, default: true
option :location, type: :string, enum: ["local", "s3"], desc: "Override the backup location"
def restore(filename = nil)
if File.exist?('/usr/local/bin/discourse')
@ -124,7 +125,7 @@ class DiscourseCLI < Thor
if !filename
puts "You must provide a filename to restore. Did you mean one of the following?\n\n"
store = BackupRestore::BackupStore.create
store = BackupRestore::BackupStore.create(location: options[:location])
store.files.each do |file|
puts "#{discourse} restore #{file.filename}"
end
@ -138,6 +139,7 @@ class DiscourseCLI < Thor
user_id: Discourse.system_user.id,
filename: filename,
disable_emails: options[:disable_emails],
location: options[:location],
factory: BackupRestore::Factory.new(user_id: Discourse.system_user.id)
)
restorer.run