diff --git a/script/discourse b/script/discourse index bbd594009c3..619232e1012 100755 --- a/script/discourse +++ b/script/discourse @@ -28,7 +28,7 @@ WHERE table_schema='public' and (data_type like 'char%' or data_type like 'text% results.each do |result| table_name = result["table_name"] column_name = result["column_name"] - puts "Reampping #{table_name} #{column_name}" + puts "Remapping #{table_name} #{column_name}" result = cnn.async_exec("UPDATE #{table_name} SET #{column_name} = replace(#{column_name}, $1, $2) WHERE NOT #{column_name} IS NULL @@ -38,25 +38,34 @@ WHERE table_schema='public' and (data_type like 'char%' or data_type like 'text% end - desc "export", "Export a Discourse backup" - def export(filename=nil) + desc "backup", "Backup a discourse forum" + def backup load_rails - filename = File.expand_path(filename) if filename + require "backup_restore" + require "export/exporter" + puts 'Starting export...' - output_filename = Jobs::Exporter.new.execute( format: :json, filename: filename) + output_filename = Export::Exporter.new(Discourse.system_user).run puts 'Export done.' puts "Output file is in: #{output_filename}", '' end - desc "import", "Import a Discourse backup" - def import(filename) + desc "export", "Backup a Discourse forum" + def export + backup + end + + desc "restore", "Restore a Discourse backup" + def restore(filename) load_rails + require "backup_restore" + require "import/importer" + begin - filename = File.expand_path(filename) puts "Starting import: #{filename}" - Jobs::Importer.new.execute( format: :json, filename: filename) + Import::Importer.new(Discourse.system_user, filename).run puts 'Import done.' rescue Import::FilenameMissingError puts '', 'The filename argument was missing.', '' @@ -67,6 +76,11 @@ WHERE table_schema='public' and (data_type like 'char%' or data_type like 'text% end end + desc "import", "Restore a Discourse backup" + def import(filename) + restore(filename) + 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