Is there any out of the box or easily supported way to replicate the database to an offsite location for a low RPO data copy? Dumping the whole DB out to a file gets clunky if you want to have a backup taken more than once per day or so.
סיכום מבוסס בינה מלאכותית
In a discussion titled “Database Replication” under the Feature category, Ghan asks whether there’s an out-of-the-box or easily supported method to replicate the Discourse database to an offsite location with a low RPO (Recovery Point Objective), noting that full DB dumps are impractical for frequent backups (e.g., every 15 minutes). merefield suggests using S3 backups, but Ghan clarifies that S3 backups still involve full database dumps each time, making them unsuitable for sub-15-minute RPOs. Falco recommends running an external PostgreSQL instance configured for replication, pointing to the guide Running Discourse with a separate PostgreSQL server, which gives full control and access to standard PostgreSQL tools. Ghan follows up, asking about potential complications during database upgrades — specifically, whether the external PostgreSQL must be upgraded before or after Discourse rebuilds. Falco responds that the user becomes responsible for maintaining and upgrading PostgreSQL, including aligning with Discourse’s supported major versions. He also suggests hosted alternatives like AWS RDS for easier management, though warns that costs may exceed Discourse’s own hosting options, which handle the full stack automatically.
Any reason why the S3 storage backup facility does not suffice?
It certainly works, but as far as I know it is the same process as local backups - write the entire database out to a file every time the backup runs and then transfer the file to S3. If I want an RPO below 15 minutes, that’s really not a good solution.
You can run an external PostgreSQL instance with the necessary replication for your use case and tell Discourse to connect to that following Running Discourse with a separate PostgreSQL server.
That way it’s all under your control and you can use standard PostgreSQL tools and features.
Oh neat, thanks for the link to that.
Are there any catches with doing this when it comes time to do database upgrades? I know with the default install Discourse typically tries to handle this on its own so would it be necessary to upgrade the database before doing a Discourse rebuild that calls for a new DB version? Or would you need to upgrade the DB after Discourse?
You will be responsible for things like keeping that PostgreSQL updated and following the major version we support. If that’s not something you are comfortable with there are hosted alternatives like AWS RDS that make it was easier. Just be aware of pricing as it can quickly become pricier than using our hosting service that can take care of the whole stack for you.