FEATURE: script/discourse import AND export
This commit is contained in:
parent
ce8bc3682f
commit
5a499b586f
|
@ -5,6 +5,35 @@ require "thor"
|
|||
class DiscourseCLI < Thor
|
||||
class_option :verbose, default: false, aliases: :v
|
||||
|
||||
desc "export", "Import a Discourse backup"
|
||||
def export(filename=nil)
|
||||
load_rails
|
||||
|
||||
filename = File.expand_path(filename) if filename
|
||||
puts 'Starting export...'
|
||||
output_filename = Jobs::Exporter.new.execute( format: :json, filename: filename)
|
||||
puts 'Export done.'
|
||||
puts "Output file is in: #{output_filename}", ''
|
||||
end
|
||||
|
||||
desc "import", "Import a Discourse backup"
|
||||
def import(filename)
|
||||
load_rails
|
||||
|
||||
begin
|
||||
filename = File.expand_path(filename)
|
||||
puts "Starting import: #{filename}"
|
||||
Jobs::Importer.new.execute( format: :json, filename: filename)
|
||||
puts 'Import done.'
|
||||
rescue Import::FilenameMissingError
|
||||
puts '', 'The filename argument was missing.', ''
|
||||
usage
|
||||
rescue Import::ImportDisabledError
|
||||
puts '', 'Imports are not allowed.', 'An admin needs to set allow_import to true in the site settings before imports can be run.', ''
|
||||
puts 'Import cancelled.', ''
|
||||
end
|
||||
end
|
||||
|
||||
desc "migrate", "Make sure all the posts are pointing to the new domain"
|
||||
option :from, type: :array, required: true, banner: "http://previous.domain.com"
|
||||
option :database, default: "default", aliases: :db
|
||||
|
|
Loading…
Reference in New Issue