Ability to "sync" post content between instances without overwriting settings/users

AI-generated summary

In a discussion about syncing Discourse post content between staging and production environments without overwriting settings or users, kalleth explains their need to sync forum data nightly while preserving environment-specific configurations and avoiding accidental emails to real users. They note that while full export/import tools exist, they’d prefer a selective sync—especially for posts and new users—without touching existing user accounts or settings. blake suggests using mailcatcher to prevent real emails from being sent during staging syncs and confirms that the only officially supported sync method is via import/export. For selective syncing, blake recommends building a custom solution using the Discourse API, noting that while bulk inserts or modifications via API are possible, there’s no built-in way to sync only new posts and users without affecting existing data. The thread highlights the gap between current tools and the desire for granular, safe cross-environment syncs.

Hi there,

Not sure this is support although it could be – here’s my use case:

For my clients’ discourse installation I have two environments; staging and production. I have a synchronisation script for the website which syncs data from production to staging each night to keep staging as close to production as possible.

I would like to do the same for discourse, but as the forums are accessible from different hostnames with different admin settings I would only like to sync the post information (and users which aren’t already present in the database, but anonymising their user account (i.e. overwriting email/real name/etc fields on the sync so there’s no PII in the staging database – i don’t want to accidentally email real people from staging!)

Is this possible right now? The import/export looks to be a bit full featured for me – i.e. it’ll nuke and overwrite everything. Am I going to have to write a rake task on each and my own importer layer? :frowning:

You could setup mailcatcher on staging to address the accidentally emailing people issue.

I believe the only supported way currently to sync data is to use the import/export tool.

If you wanted something to just sync post data and new users you will probably need to write your own sync functionality using the discourse_api. Using the api you should be able to get all the new posts and users, but I don’t think there is a good way to bulk insert or modify the dates on insert to match production using the api.

You could also find the right tables in postgres and export and import those directly.

1 Curtiu