There’s a command line tool to export a set of arbitrary topics or an entire category.
The tool can be run from the base directory of the Discourse project:
su - discourse cd /var/www/discourse
The topic exporter will export all topics, posts, and all users who participated in those topics.
Get the topic IDs. For example, let’s say you want to export these two topics:
Run this command:
bundle exec script/discourse export_topics 25 27
Output should look something like this:
Starting export of topics... Best dance moves Hurt myself dancing Export saved to topic-export-2016-02-02-165613.json Done
To import it into another Discourse site, move the output file to the other Discourse server and run the topic importer:
bundle exec script/discourse import_topics topic-export-2016-02-02-165613.json
In a multisite environment, use the RAILS_DB env variable.
RAILS_DB=xxxmoves bundle exec script/discourse export_topics 25 27 RAILS_DB=dancerehab bundle exec script/discourse import_topics topic-export-2016-02-02-165613.json
The category exporter will export:
- the category
- all its subcategories
- its security settings
- custom groups mentioned in the security settings
- all topics and posts in the category and subcategories
- all users who posted, and assigns them to the groups
With the category id, run it like this:
bundle exec script/discourse export_category 5
And import it like this:
bundle exec script/discourse import_category category-export-2016-02-02-154352.json