# Configure automatic backups for Discourse

**URL:** https://meta.discourse.org/t/configure-automatic-backups-for-discourse/14855
**Category:** Self-Hosting
**Tags:** backups, how-to
**Created:** [April 18, 2014, 6:21am UTC](https://meta.discourse.org/t/configure-automatic-backups-for-discourse/14855 "2014-04-18T06:21:44Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Discourse](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/discourse/32/148734_2.png) [@Discourse](https://meta.discourse.org/u/Discourse)
#### Post date: [April 18, 2014, 6:21am UTC](https://meta.discourse.org/t/configure-automatic-backups-for-discourse/14855/1 "2014-04-18T06:21:44Z")

</div>

> 🔖 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 automatic backups for your Discourse platform.

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

## Configuring automatic backups

1. Navigate to `/admin` settings.
2. Select the **Backup** section.
3. Set `backup_frequency` to the desired interval in days. The default is `7` (weekly). Set to `1` for daily backups, or `0` to disable automatic backups. The maximum is `30`.

![backup_frequency](https://global.discourse-cdn.com/meta/optimized/3X/c/2/c27177c16702c8746ea9b19e069c036b2eff21b3_2_690x51.png)backup\_frequency100%75%50%

### Additional backup settings

- `backup_time_of_day` — the time of day (UTC) when backups run. Default: `3:30`.
- `backup_with_uploads` — include uploads in scheduled backups. Default: enabled. Disabling this will only back up the database.
- `maximum_backups` — the maximum number of backups to keep. Older backups are automatically deleted. Default: `5`.
- `remove_older_backups` — remove backups older than the specified number of days. Leave blank to disable.

## 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.

- _Follow steps in_ [setting up S3 uploads](https://meta.discourse.org/t/setting-up-file-and-image-uploads-to-s3/7229).

1. Configure `s3_access_key_id`, `s3_secret_access_key`, and `s3_region`.
2. Set `backup_location` to “S3”.

 ![S3 configuration](https://global.discourse-cdn.com/meta/original/3X/2/b/2bca621b0b105d6b0cc7d51c49bd4de35fbbc588.png)

![image](https://global.discourse-cdn.com/meta/optimized/3X/8/6/8690e780bf02eb8f9b1d1de52a889cb6c86fc97a_2_690x53.png)

> ⚠ **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.

 ![image](https://global.discourse-cdn.com/meta/original/3X/f/4/f44b4e00b8a12b1ab8113087aa3439047294709a.png)

### 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](https://meta.discourse.org/t/configure-an-s3-compatible-object-storage-provider-for-uploads/148916)

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):

```bash
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](https://docs.aws.amazon.com/AmazonS3/latest/userguide/lifecycle-transition-general-considerations.html) 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 document**
> >
> > Perform check on document:

---

<div class="post-metadata">

### Author: ![Frez](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/frez/32/49215_2.png) [@Frez](https://meta.discourse.org/u/Frez)
#### Post date: [January 18, 2016, 3:49pm UTC](https://meta.discourse.org/t/configure-automatic-backups-for-discourse/14855/44 "2016-01-18T15:49:00Z")

</div>

> [@codinghorror](#):
>
> Note that you can also enable an automatic move to Glacier bucket lifecycle rule to keep your S3 backup costs low.

Setting this up can be rather confusing. Here’s a simple guide to help you out.

- Log into your Discourse admin panel
- Configure daily backups
- Set maximum backups to 7
- Log into your Amazon Web Services account
- Go in the S3 Dashboard
- Open the bucket containing the backups
- Click on the properties tab
- Activate versioning
- Open the Lifecycle menu
- Add a rule for the whole bucket
- Set current version to expire after 15 days
- Set previous version to
- Archive to Glacier after 1 days
- expire after 91 days
- Save and logout

### How it works

Versioning will keep backups automaticly deleted by Discourse. One day after beeing deleted it will be moved to the Glacier storage. After 91 days it will be delete from the Glacier storage.

**Warning**

Amazon charge you for item stored in Glacier for 90 days even if you delete them before. Make sure your Glacier Lyfecicle keep your file at least 90 days.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [January 4, 2021, 10:24pm UTC](https://meta.discourse.org/t/configure-automatic-backups-for-discourse/14855/102 "2021-01-04T22:24:52Z")

</div>

> [@codinghorror](#):
>
> So you’d like to automatically back up all your Discourse data every day?

Is there a good reason not to make daily backups aren’t the default?

### Fixes needed for OP

Add something about moving S3 backups to Glacier?  
 Delete the S3 stuff and link to [Configure an S3 compatible object storage provider for uploads](https://meta.discourse.org/t/using-object-storage-for-uploads-s3-clones/148916)

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [November 29, 2022, 8:41pm UTC](https://meta.discourse.org/t/configure-automatic-backups-for-discourse/14855/128 "2022-11-29T20:41:10Z")

</div>

> [@Sectros](#):
>
> where in the vps are the backups stored?

I added this to the OP:

> [@Discourse](#):
>
> If you’re self-hosted you can access them at `/var/discourse/shared/standalone/backups/default`.
