# Local backups not deleted after they are uploaded to Amazon S3

**URL:** https://meta.discourse.org/t/local-backups-not-deleted-after-they-are-uploaded-to-amazon-s3/247371
**Category:** Support
**Tags:** backups, s3
**Created:** [December 1, 2022, 5:11pm UTC](https://meta.discourse.org/t/local-backups-not-deleted-after-they-are-uploaded-to-amazon-s3/247371 "2022-12-01T17:11:56Z")
**Posts on this page:** 14
**Page:** 1

<div class="post-metadata">

### Author: ![omarfilip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/omarfilip/32/208019_2.png) [@omarfilip](https://meta.discourse.org/u/omarfilip)
#### Post date: [December 1, 2022, 5:11pm UTC](https://meta.discourse.org/t/local-backups-not-deleted-after-they-are-uploaded-to-amazon-s3/247371/1 "2022-12-01T17:11:56Z")

</div>

My backups keep accumulating in `/var/discourse/shared/standalone/backups/default` even though they are uploaded to Amazon S3.

Here’s my Discourse setup:

 ![Discourse backups settings](https://global.discourse-cdn.com/meta/original/4X/2/e/c/2ecf349a94af2d1bd627a056c8b7874585d53a41.png)

Discourse backups:

 ![discourse backups](https://global.discourse-cdn.com/meta/original/4X/6/b/5/6b5682f7d4587716fe3e9fa32cb4bcd34216bf4f.png)

Backups in the S3 bucket:

 ![Screenshot 2022-12-01 at 8.50.24 AM](https://global.discourse-cdn.com/meta/original/4X/7/1/5/715415279cff33e5909b71a59bf650ee5ad95d5b.png)

And the contents of `/var/discourse/shared/standalone/backups/default`:

 ![backups-default dir](https://global.discourse-cdn.com/meta/original/4X/a/9/3/a937bc6d192bf343c69a6ea2d431e66018b888fa.png)

This has been going on for a long time—I have a monthly reminder in my calendar to delete these leftover files. Backup logs are empty: “No logs yet…” and nothing in error logs points to problems with Amazon S3.

Discourse is updated regularly and currently 2.9.0.beta14.

---

<div class="post-metadata">

### Author: ![gerhard](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gerhard/32/119479_2.png) [@gerhard](https://meta.discourse.org/u/gerhard)
#### Post date: [December 1, 2022, 6:08pm UTC](https://meta.discourse.org/t/local-backups-not-deleted-after-they-are-uploaded-to-amazon-s3/247371/2 "2022-12-01T18:08:38Z")

</div>

This is a [standard install](https://meta.discourse.org/t/142537?silent=true), right? Is there a chance that the OS (or something else) is killing the backup process during the upload? Because even when there’s a backup failure, the local file should be deleted at the end of the process.

---

<div class="post-metadata">

### Author: ![omarfilip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/omarfilip/32/208019_2.png) [@omarfilip](https://meta.discourse.org/u/omarfilip)
#### Post date: [December 1, 2022, 6:10pm UTC](https://meta.discourse.org/t/local-backups-not-deleted-after-they-are-uploaded-to-amazon-s3/247371/3 "2022-12-01T18:10:43Z")

</div>

Yes, [standard install](https://meta.discourse.org/t/142537?silent=true) on a DigitalOcean droplet, Ubuntu 16.04.7 LTS. Where would the relevant log be?

---

<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: [December 2, 2022, 8:38am UTC](https://meta.discourse.org/t/local-backups-not-deleted-after-they-are-uploaded-to-amazon-s3/247371/4 "2022-12-02T08:38:23Z")

</div>

I used some S3 compatible service for a while that sometimes resulted in backups being left on the local drive, but it was intermittent.

You’d look in `/var/discourse/shared/standalone/logs/rails/production.log`. It just run a command line backup and see if it has the and behavior.

---

<div class="post-metadata">

### Author: ![omarfilip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/omarfilip/32/208019_2.png) [@omarfilip](https://meta.discourse.org/u/omarfilip)
#### Post date: [December 2, 2022, 5:01pm UTC](https://meta.discourse.org/t/local-backups-not-deleted-after-they-are-uploaded-to-amazon-s3/247371/5 "2022-12-02T17:01:06Z")

</div>

Production logs only go back a week, so the older “undeleted” backups fall out of that range, but I’ll keep an eye on the future ones. The only backup error entry was this in the 11/30 log:

```plaintext
Started GET "/.env.backup" for 3.236.147.46 at 2022-11-29 19:15:57 +0000
ActionController::RoutingError (No route matches [GET] "/.env.backup")

```

---

<div class="post-metadata">

### Author: ![omarfilip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/omarfilip/32/208019_2.png) [@omarfilip](https://meta.discourse.org/u/omarfilip)
#### Post date: [December 13, 2022, 8:19pm UTC](https://meta.discourse.org/t/local-backups-not-deleted-after-they-are-uploaded-to-amazon-s3/247371/6 "2022-12-13T20:19:41Z")

</div>

I see a new undeleted backup in `/var/discourse/shared/standalone/backups/default` but nothing in the production.log. Nothing in the production\_errors.log either. Where else could I look?

P.S. I ran a backup from the CLI and the backup was successfully removed - I’ll try that a few more times to see if I can get an error there.

---

<div class="post-metadata">

### Author: ![omarfilip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/omarfilip/32/208019_2.png) [@omarfilip](https://meta.discourse.org/u/omarfilip)
#### Post date: [December 16, 2022, 6:44pm UTC](https://meta.discourse.org/t/local-backups-not-deleted-after-they-are-uploaded-to-amazon-s3/247371/7 "2022-12-16T18:44:25Z")

</div>

Not having success reproducing the undeleted local backup via CLI, but it does keep happening once or twice a week during the nightly backup. I also don’t see any of the backup log output in production.log. Are you sure that’s where it’s written, @pfaffman ?

---

<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: [December 16, 2022, 6:46pm UTC](https://meta.discourse.org/t/local-backups-not-deleted-after-they-are-uploaded-to-amazon-s3/247371/8 "2022-12-16T18:46:42Z")

</div>

> [@omarfilip](#):
>
> Are you sure that’s where it’s written, @pfaffman ?

I think it should be. When I had a similar problem with `some other S3 service`, I was unable to find errors in either Discourse or their service. And I gave up and switched to something different. But you’re using AWS, S3, the Real Deal, so I’m quite surprised.

---

<div class="post-metadata">

### Author: ![omarfilip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/omarfilip/32/208019_2.png) [@omarfilip](https://meta.discourse.org/u/omarfilip)
#### Post date: [December 16, 2022, 6:57pm UTC](https://meta.discourse.org/t/local-backups-not-deleted-after-they-are-uploaded-to-amazon-s3/247371/9 "2022-12-16T18:57:21Z")

</div>

I’ve tried looking like this:  
`grep -r "Output file is stored on S3" /var/discourse`  
as that phrase is the last line of the CLI backup output, but nothing is found.

---

<div class="post-metadata">

### Author: ![gerhard](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gerhard/32/119479_2.png) [@gerhard](https://meta.discourse.org/u/gerhard)
#### Post date: [December 16, 2022, 7:46pm UTC](https://meta.discourse.org/t/local-backups-not-deleted-after-they-are-uploaded-to-amazon-s3/247371/10 "2022-12-16T19:46:56Z")

</div>

Any chance that the server reboots due to automatic updates of the host OS? They might happen while the upload to S3 is in progress. Is there anything in the logs of your OS? Maybe reset the `backup_time_of_day` site setting to the default value or a different time and see if the problem disappears.

---

<div class="post-metadata">

### Author: ![omarfilip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/omarfilip/32/208019_2.png) [@omarfilip](https://meta.discourse.org/u/omarfilip)
#### Post date: [December 16, 2022, 7:53pm UTC](https://meta.discourse.org/t/local-backups-not-deleted-after-they-are-uploaded-to-amazon-s3/247371/11 "2022-12-16T19:53:39Z")

</div>

No, current uptime is 36 days. I had suspected that the DigitalOcean droplet backup running concurrently might have been the cause, but that happens once a week and my undeleted backups occur more frequently than that.

I’ll try a different `backup_time_of_day`. It was set to 2:00 UTC, so we’ll see if the default 3:30 UTC makes any difference.

---

<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: [December 16, 2022, 8:07pm UTC](https://meta.discourse.org/t/local-backups-not-deleted-after-they-are-uploaded-to-amazon-s3/247371/12 "2022-12-16T20:07:02Z")

</div>

> [@gerhard](#):
>
> Any chance that the server reboots due to automatic updates of the host OS?

OOOOH! That’s a good one. That would explain it. I bet that’s it. And the middle of the night is a Good Time for both backups and reboots. It doesn’t quite explain why the problem went away when I changed to a different service, but maybe my luck just changed, or whatever I changed to was faster or something.

> [@omarfilip](#):
>
> No, current uptime is 36 days.

Oh. Darn. 😿

---

<div class="post-metadata">

### Author: ![omarfilip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/omarfilip/32/208019_2.png) [@omarfilip](https://meta.discourse.org/u/omarfilip)
#### Post date: [January 1, 2023, 10:34pm UTC](https://meta.discourse.org/t/local-backups-not-deleted-after-they-are-uploaded-to-amazon-s3/247371/13 "2023-01-01T22:34:29Z")

</div>

> [@gerhard](#):
>
> Maybe reset the `backup_time_of_day` site setting to the default value or a different time and see if the problem disappears.

> [@omarfilip](#):
>
> I’ll try a different `backup_time_of_day`. It was set to 2:00 UTC, so we’ll see if the default 3:30 UTC makes any difference.

Sixteen days later, it seems like this was the solution—no more undeleted backups. I don’t know what was causing the conflict, but it’s moot now.

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [January 31, 2023, 10:34pm UTC](https://meta.discourse.org/t/local-backups-not-deleted-after-they-are-uploaded-to-amazon-s3/247371/14 "2023-01-31T22:34:54Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
