Skip to content

Commit

Permalink
FEATURE: script/discourse import AND export
Browse files Browse the repository at this point in the history
  • Loading branch information
SamSaffron committed Jan 17, 2014
1 parent ce8bc36 commit 5a499b5
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions script/discourse
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 5a499b5

Please sign in to comment.