# Discourse not cleaning-up local tmp backups after uploading to S3

**URL:** https://meta.discourse.org/t/discourse-not-cleaning-up-local-tmp-backups-after-uploading-to-s3/291033
**Category:** Self-hosting
**Tags:** backups, s3
**Created:** [January 9, 2024, 3:51pm UTC](https://meta.discourse.org/t/discourse-not-cleaning-up-local-tmp-backups-after-uploading-to-s3/291033 "2024-01-09T15:51:44Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![Wingtip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/wingtip/32/102039_2.png) [@Wingtip](https://meta.discourse.org/u/Wingtip)
#### Post date: [January 9, 2024, 3:51pm UTC](https://meta.discourse.org/t/discourse-not-cleaning-up-local-tmp-backups-after-uploading-to-s3/291033/1 "2024-01-09T15:51:44Z")

</div>

Running 3.2.0.beta4-dev ( [86da47f58d](https://github.com/discourse/discourse/commits/86da47f58dab2bad66929c3708830c264e311451) ) but we’ve had this problem for awhile now.

We have backups configured to go straight to S3. Understandably the application takes it to local storage first then uploads to S3, which is fine. Problem is it doesn’t _delete_ each backup after uploading leading to tons of space usage even without thumbnails saved inside the backups.

```plaintext
root@forum:/var/discourse/shared/standalone/tmp/backups/default# du -sh
57G .
root@forum:/var/discourse/shared/standalone/tmp/backups/default# du -k
7073520 ./2023-12-28-063845
8040176 ./2023-12-29-063923
8521220 ./2024-01-08-063857
4909616 ./2023-12-24-064434
4918056 ./2024-01-07-064325
7079136 ./2024-01-03-064430
7077984 ./2024-01-02-063855
2949660 ./2024-01-09-063708
59088404 .
root@forum:/var/discourse/shared/standalone/tmp/backups/default# rm -Rf *

```

Could this be a permissions issue on the directory, possibly? I certainly haven’t changed it.

```plaintext
root@forum:/var/discourse/shared/standalone/tmp/backups# ls -la
total 12
drwxr-xr-x 3 mas www-data 4096 Nov 23 06:44 .
drwxr-xr-x 4 mas www-data 4096 Nov 22 04:57 ..
drwxr-xr-x 2 mas www-data 4096 Jan 9 15:35 default

```

What’s weird is from the tmp files listing, we see jan 2, 3, 7, 8, and 9 consuming space. From the Discourse backup listing in the admin UI, I only see Jan 4th. So maybe Discourse is taking those backups but not properly uploading them to S3? Problem with that theory is “backup frequency” is set to 3 in the admin configuration, so it shouldn’t be trying to backup every day anyway. Note backup logs in the admin UI is empty, no logs there.

 ![image](https://global.discourse-cdn.com/meta/original/4X/2/d/7/2d7105c926a0a07d9b364a0e60a7efc7edeae548.png)

 ![Untitled](https://global.discourse-cdn.com/meta/original/4X/1/c/1/1c162d76ccbb69f9232c3c04a482133585bee61c.png)

---

<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 9, 2024, 4:44pm UTC](https://meta.discourse.org/t/discourse-not-cleaning-up-local-tmp-backups-after-uploading-to-s3/291033/2 "2024-01-09T16:44:52Z")

</div>

My best explanation is that sometimes the server reboots before it can delete the local backup file.

> [@Wingtip](#):
>
> What’s weird is from the tmp files listing, we see jan 2, 3, 7, 8, and 9 consuming space. From the Discourse backup listing in the admin UI, I only see Jan 4th.

The backup listing shows what’s on S3, not on your local drive.

> [@Wingtip](#):
>
> “backup frequency” is set to 3 in the admin configuration, so it shouldn’t be trying to backup every day anyway

Is someone manually running a backup?

---

<div class="post-metadata">

### Author: ![Wingtip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/wingtip/32/102039_2.png) [@Wingtip](https://meta.discourse.org/u/Wingtip)
#### Post date: [January 9, 2024, 5:22pm UTC](https://meta.discourse.org/t/discourse-not-cleaning-up-local-tmp-backups-after-uploading-to-s3/291033/3 "2024-01-09T17:22:21Z")

</div>

The host has 90d uptime and the docker container has 6 weeks of uptime, so no actual reboots, unless you’re talking about something inside the application.

No manual backups from me, certainly not one every single day. Nothing in cron etc either.

```plaintext
root@forum:/# uptime
 17:20:56 up 90 days, 1:52, 4 users, load average: 0.81, 1.71, 1.81
root@forum:/# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d8bc34250454 local_discourse/app "/sbin/boot" 6 weeks ago Up 6 weeks 0.0.0.0:80->80/tcp, :::80->80/tcp, 0.0.0.0:443->443/tcp, :::443->443/tcp app

```

---

<div class="post-metadata">

### Author: ![Wingtip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/wingtip/32/102039_2.png) [@Wingtip](https://meta.discourse.org/u/Wingtip)
#### Post date: [January 16, 2024, 3:33pm UTC](https://meta.discourse.org/t/discourse-not-cleaning-up-local-tmp-backups-after-uploading-to-s3/291033/4 "2024-01-16T15:33:28Z")

</div>

Still happening, sigh. I guess I’ll cron a find -mtime +2 -delete. Good times.

```plaintext
root@forum:/var/discourse/shared/standalone/tmp/backups/default# du -sh
14G .
root@forum:/var/discourse/shared/standalone/tmp/backups/default# ls -la
total 16
drwxr-xr-x 4 mas www-data 4096 Jan 16 06:56 .
drwxr-xr-x 3 mas www-data 4096 Nov 23 06:44 ..
drwxr-xr-x 2 mas www-data 4096 Jan 14 06:38 2024-01-14-063807
drwxr-xr-x 2 mas www-data 4096 Jan 15 06:43 2024-01-15-064337

```

---

<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 16, 2024, 4:53pm UTC](https://meta.discourse.org/t/discourse-not-cleaning-up-local-tmp-backups-after-uploading-to-s3/291033/5 "2024-01-16T16:53:30Z")

</div>

> [@Wingtip](#):
>
> The host has 90d uptime and the docker container has 6 weeks of uptime, so no actual reboots, unless you’re talking about something inside the application.

Darn. That was my best guess.

> [@Wingtip](#):
>
> Still happening, sigh. I guess I’ll cron a find -mtime +2 -delete. Good times.

Yeah. That might be what to do.

---

<div class="post-metadata">

### Author: ![Wingtip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/wingtip/32/102039_2.png) [@Wingtip](https://meta.discourse.org/u/Wingtip)
#### Post date: [January 16, 2024, 5:47pm UTC](https://meta.discourse.org/t/discourse-not-cleaning-up-local-tmp-backups-after-uploading-to-s3/291033/6 "2024-01-16T17:47:55Z")

</div>

Done. Not the most elegant or satisfying solution, but I guess problem solved.

---

<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 16, 2024, 5:59pm UTC](https://meta.discourse.org/t/discourse-not-cleaning-up-local-tmp-backups-after-uploading-to-s3/291033/7 "2024-01-16T17:59:11Z")

</div>

Yeah. I think that’s what I’ll do the next time I have this problem.
