Configure automatic backups for Discourse

:bookmark: This guide explains how to configure automatic backups for Discourse, including storage options on local servers and S3-compatible storage.

Learn how to set up daily automatic backups for your Discourse platform.

This guide covers configuring daily backups, storing them on local servers or S3-compatible storage, and managing storage retention options like Amazon Glacier.

Configuring daily backups

  1. Navigate to /admin settings.
  2. Select the Backup section.
  3. Set the backup_frequency to 1.

backup_frequencybackup_frequency100%75%50%

Store backups on the local server

By default, backups are stored on your local server. For self-hosted instances, access them at /var/discourse/shared/standalone/backups/default.

Store backups on S3-compatible storage

Using the admin panel

  1. Create an S3 bucket.
  2. Set the s3_backup_bucket in the admin panel.
  1. Configure s3_access_key_id, s3_secret_access_key, and s3_region.
  2. Set backup_location to β€œS3”.

image

:warning: WARNING

Storing backups and regular uploads in the same bucket and folder is no longer supported and will not work.

The s3_backup_bucket path should only be used for backups. If you need to use a bucket that contains other files please make sure that you provide a prefix when you configure the s3_backup_bucket setting (example: my-awesome-bucket/backups) and make sure that files with that prefix are private.

From now on all backups will be uploaded to S3 and not be stored locally anymore. Local storage will only be used for temporary files during backups and restores.

Go to the Backups tab in the admin dashboard to browse the backups – you can download them any time to do a manual offsite backup.

Using environment variables in app.yml

You can also configure S3 backups using environment variables in app.yml. For more information, see Configure an S3 compatible object storage provider for uploads

Note that the above article covers app.yml covers S3 setup for backups and for file/image uploads. If you only want to use S3 for backups (and not for uploads of files/images), then you can omit the following parameters from your app.yml config:

  • DISCOURSE_USE_S3
  • DISCOURSE_S3_CDN_URL
  • DISCOURSE_S3_BUCKET

You also don’t need to configure the after_assets_precompile step in this case, nor configure a CDN.

Be sure to include all other parameters that are required for your storage provider, as mentioned in the article. Here is one example configuration that only activates S3 for backups (for Scaleway S3):

DISCOURSE_S3_REGION: nl-ams
DISCOURSE_S3_ENDPOINT: https://s3.nl-ams.scw.cloud
DISCOURSE_S3_ACCESS_KEY_ID: my_access_key
DISCOURSE_S3_SECRET_ACCESS_KEY: my_secret_access_key
DISCOURSE_S3_BACKUP_BUCKET: my_bucket/my_folder
DISCOURSE_BACKUP_LOCATION: s3

Archiving to storage with a lower cost

Note that on AWS S3, you can also enable an automatic move to Glacier bucket lifecycle rule to keep your S3 backup costs low. Other storage providers often have a similar offering.

Last edited by @SaraDev 2024-11-07T20:36:45Z

Check documentPerform check on document:
57 Likes