# 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:** 20
**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: ![olivermark83](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/olivermark83/32/39044_2.png) [@olivermark83](https://meta.discourse.org/u/olivermark83)
#### Post date: [February 19, 2015, 5:34pm UTC](https://meta.discourse.org/t/configure-automatic-backups-for-discourse/14855/23 "2015-02-19T17:34:25Z")

</div>

You are able to Archive Backups from your S3 Bucket to Glacier.  
It is cheaper, but an Restore attemps more Time.

This Site will Help you to reduce Backup costs.:

> **[Archiving Amazon S3 Data to Amazon Glacier | Amazon Web Services](https://aws.amazon.com/de/blogs/aws/archive-s3-to-glacier/)**
>
> (Editor’s note, April 22, 2022: Since this article was originally published, additional helpful resources have also become available, including Getting started using the Amazon S3 Glacier storage classes and Best practices for archiving large...

![](https://global.discourse-cdn.com/meta/original/3X/1/8/18031dd6f06c5602b15a0225ac216658ca2f6081.png)

---

<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: ![MarcP](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/marcp/32/160184_2.png) [@MarcP](https://meta.discourse.org/u/MarcP)
#### Post date: [November 16, 2019, 12:43am UTC](https://meta.discourse.org/t/configure-automatic-backups-for-discourse/14855/98 "2019-11-16T00:43:05Z")

</div>

I may have missed this, but how to I make sure a bucket for backups is private the proper way? [Set up file and image uploads to S3](https://meta.discourse.org/t/setting-up-file-and-image-uploads-to-s3/7229) doesn’t seem to be described here.

---

<div class="post-metadata">

### Author: ![Alex\_P](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/alex_p/32/163548_2.png) [@Alex\_P](https://meta.discourse.org/u/Alex_P)
#### Post date: [December 22, 2019, 3:33pm UTC](https://meta.discourse.org/t/configure-automatic-backups-for-discourse/14855/99 "2019-12-22T15:33:21Z")

</div>

> [@Frez](#):
>
> Set current version to expire after 15 days

Looks like there is no such option anymore.

UPD: ah, now it’s split into 2 steps of this wizard.

So I guess it should be like this:

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

 ![image](https://global.discourse-cdn.com/meta/original/3X/9/0/90038c763c2d9c54896a216efaa8d31398710411.png)

 ![image](https://global.discourse-cdn.com/meta/original/3X/e/6/e6241b9cff17441530f3775cea7745be05bddf91.png)

---

<div class="post-metadata">

### Author: ![jorymorrison](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jorymorrison/32/162963_2.png) [@jorymorrison](https://meta.discourse.org/u/jorymorrison)
#### Post date: [March 30, 2020, 8:32pm UTC](https://meta.discourse.org/t/configure-automatic-backups-for-discourse/14855/100 "2020-03-30T20:32:17Z")

</div>

Does S3 backup functionality play nice without IAM access key and secret if using AWS roles assigned to the instance and `s3 use iam profile` is enabled in the `settings` menu?

Edit: The answer is YES! Just ensure you have region set appropriately.

---

<div class="post-metadata">

### Author: ![nathank](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nathank/32/290039_2.png) [@nathank](https://meta.discourse.org/u/nathank)
#### Post date: [December 5, 2020, 7:09am UTC](https://meta.discourse.org/t/configure-automatic-backups-for-discourse/14855/101 "2020-12-05T07:09:18Z")

</div>

> [@Set up file and image uploads to S3](https://meta.discourse.org/t/set-up-file-and-image-uploads-to-s3/7229/164):
>
> I am a bit confused with how to use this guide to configure backups as well.
> 
> I did what I thought made sense but I’ve gotten a little lost along the way and now I am getting “Failed to access backup storage: Access Denied”

I had this problem too, which was resolved by adding a couple of lines to the policy document:

```plaintext
"Resource": [
        "arn:aws:s3:::your-uploads-bucket",
        "arn:aws:s3:::your-uploads-bucket/*",
        "arn:aws:s3:::your-backups-bucket",
        "arn:aws:s3:::your-backups-bucket/*"
      ]

```

Should this be added to the OP (which isn’t a wiki)? Or perhaps in the OP of [Set up file and image uploads to S3](https://meta.discourse.org/t/setting-up-file-and-image-uploads-to-s3/7229)?

---

<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: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [January 4, 2021, 10:41pm UTC](https://meta.discourse.org/t/configure-automatic-backups-for-discourse/14855/103 "2021-01-04T22:41:22Z")

</div>

> [@pfaffman](#):
>
> Is there a good reason not to make daily backups aren’t the default?

It’d be overkill and expensive. Same reason we don’t recommend changing the oil in your car every 500 miles?

---

<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, 11:01pm UTC](https://meta.discourse.org/t/configure-automatic-backups-for-discourse/14855/104 "2021-01-04T23:01:27Z")

</div>

> [@codinghorror](#):
>
> It’d be overkill and expensive.

You back up your servers once a week?

I think your 500 mile oil change analogy would be a good answer for “why not keep 30 backups?”, but it doesn’t make sense to me here.

Do you not think that if you’re going to have 5 backups most people would rather have backups every day so that if they do have to revert to a backup they’ve lost no more than a day? The only time I remember an older backup being useful is when images fell out of tombstone.

If they have so little disk space that they can’t hold 5 backups, it would seem better to learn that in 5 days when they still have some memory of what they did than wait 4-5 weeks.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [January 4, 2021, 11:21pm UTC](https://meta.discourse.org/t/configure-automatic-backups-for-discourse/14855/105 "2021-01-04T23:21:45Z")

</div>

> [@pfaffman](#):
>
> You back up your servers once a week?

Yes, that is correct, for my self hosted servers.

If you prefer different settings, feel free to edit them from the defaults. What’s stopping you from doing so?

---

<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 5, 2021, 4:12am UTC](https://meta.discourse.org/t/configure-automatic-backups-for-discourse/14855/106 "2021-01-05T04:12:46Z")

</div>

> [@codinghorror](#):
>
> Yes, that is correct, for my self hosted servers.

Well, I’ll be!

> [@codinghorror](#):
>
> What’s stopping you from doing so?

I’m cleaning up topics like this one. If the defaults were changed, it wouldn’t be needed!

I’m convinced that the defaults won’t be changed, so I’ll move ahead. :wink

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [January 6, 2021, 4:32am UTC](https://meta.discourse.org/t/configure-automatic-backups-for-discourse/14855/107 "2021-01-06T04:32:04Z")

</div>

Once a week is a good starting point and a solid default.

---

<div class="post-metadata">

### Author: ![Discoursecurious](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/discoursecurious/32/119542_2.png) [@Discoursecurious](https://meta.discourse.org/u/Discoursecurious)
#### Post date: [January 25, 2021, 5:04pm UTC](https://meta.discourse.org/t/configure-automatic-backups-for-discourse/14855/108 "2021-01-25T17:04:42Z")

</div>

> [@Set up file and image uploads to S3](https://meta.discourse.org/t/set-up-file-and-image-uploads-to-s3/7229/164):
>
> > [@Set up file and image uploads to S3](https://meta.discourse.org/t/set-up-file-and-image-uploads-to-s3/7229/164):
> >
> > I am a bit confused with how to use this guide to configure backups as well.
> > 
> > > I did what I thought made sense but I’ve gotten a little lost along the way and now I am getting “Failed to access backup storage: Access Denied”
> 
> I had this problem too, which was resolved by adding a couple of lines to the policy document:
> 
> ```plaintext
> "Resource": [
> "arn:aws:s3:::your-uploads-bucket",
> "arn:aws:s3:::your-uploads-bucket/*",
> "arn:aws:s3:::your-backups-bucket",
> "arn:aws:s3:::your-backups-bucket/*"
> ]
> 
> ```
> 
> Should this be added to the OP (which isn’t a wiki)? Or perhaps in the OP of [Setting up file and image uploads to S3](https://meta.discourse.org/t/setting-up-file-and-image-uploads-to-s3/7229)?

I had the very same problem!

i suggest to add a note regarding this on the initial post too!

---

<div class="post-metadata">

### Author: ![jessicah](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jessicah/32/102653_2.png) [@jessicah](https://meta.discourse.org/u/jessicah)
#### Post date: [April 1, 2021, 3:53am UTC](https://meta.discourse.org/t/configure-automatic-backups-for-discourse/14855/109 "2021-04-01T03:53:48Z")

</div>

Would be nice if this could be used to upload to a different S3 compatible provider, such as running MinIO.

---

<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: [April 1, 2021, 11:55am UTC](https://meta.discourse.org/t/configure-automatic-backups-for-discourse/14855/110 "2021-04-01T11:55:44Z")

</div>

If you want to use minio, see [Using Object Storage for Uploads (S3 & Clones)](https://meta.discourse.org/t/using-object-storage-for-uploads-s3-clones/148916). If you want different services for backups and assets then you’re out of luck (though there are ways to set up triggers to copy from one bucket 8 another)

---

<div class="post-metadata">

### Author: ![jessicah](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jessicah/32/102653_2.png) [@jessicah](https://meta.discourse.org/u/jessicah)
#### Post date: [April 1, 2021, 12:51pm UTC](https://meta.discourse.org/t/configure-automatic-backups-for-discourse/14855/111 "2021-04-01T12:51:02Z")

</div>

No, just want for backups, so they get automatically pushed to a different machine on my network.

---

<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: [April 1, 2021, 12:51pm UTC](https://meta.discourse.org/t/configure-automatic-backups-for-discourse/14855/112 "2021-04-01T12:51:43Z")

</div>

Then the guide I linked is what you’re looking for.

---

<div class="post-metadata">

### Author: ![Tris20](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tris20/32/264639_2.png) [@Tris20](https://meta.discourse.org/u/Tris20)
#### Post date: [September 19, 2021, 10:16am UTC](https://meta.discourse.org/t/configure-automatic-backups-for-discourse/14855/113 "2021-09-19T10:16:00Z")

</div>

Is it possible to be more frequent than once per day? I’d rather not make assumptions and set backup freqeuncy to a float

---

<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: [September 19, 2021, 10:40am UTC](https://meta.discourse.org/t/configure-automatic-backups-for-discourse/14855/114 "2021-09-19T10:40:44Z")

</div>

If you want more frequent backups you’ll need to do them externally.

[Next page](https://meta.discourse.org/t/configure-automatic-backups-for-discourse/14855.md?page=2)
