# How to purge data older than 3months?

**URL:** https://meta.discourse.org/t/how-to-purge-data-older-than-3months/352137
**Category:** Support
**Created:** [February 13, 2025, 7:14pm UTC](https://meta.discourse.org/t/how-to-purge-data-older-than-3months/352137 "2025-02-13T19:14:28Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![hmmmnotsure](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/hmmmnotsure/32/472794_2.png) [@hmmmnotsure](https://meta.discourse.org/u/hmmmnotsure)
#### Post date: [February 13, 2025, 7:14pm UTC](https://meta.discourse.org/t/how-to-purge-data-older-than-3months/352137/1 "2025-02-13T19:14:28Z")

</div>

hey!

How do i keep only last 3 months’ data and purge the rest? Via admin console? Thanks.

---

<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: [February 14, 2025, 12:35am UTC](https://meta.discourse.org/t/how-to-purge-data-older-than-3months/352137/2 "2025-02-14T00:35:22Z")

</div>

What data? What problem are you solving?

---

<div class="post-metadata">

### Author: ![hmmmnotsure](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/hmmmnotsure/32/472794_2.png) [@hmmmnotsure](https://meta.discourse.org/u/hmmmnotsure)
#### Post date: [February 18, 2025, 6:16pm UTC](https://meta.discourse.org/t/how-to-purge-data-older-than-3months/352137/3 "2025-02-18T18:16:04Z")

</div>

Thank you for your reply. We are trying to see how we can reduce the db size on our stage environment.

---

<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: [February 19, 2025, 3:54am UTC](https://meta.discourse.org/t/how-to-purge-data-older-than-3months/352137/4 "2025-02-19T03:54:13Z")

</div>

You’d have to restore the whole database, so what’s the point? And if you deleted a bunch of data then it wouldn’t be useful as a test of what’s on production?

But there is a PostDestroyer and you could do a User.where(something).destroy\_all, but that doesn’t seem very useful

What do you think you’re going to test on the staging site if it isn’t the data from production? Maybe you just want to generate some bogus data? I think there is a rake task for that.

---

<div class="post-metadata">

### Author: ![hmmmnotsure](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/hmmmnotsure/32/472794_2.png) [@hmmmnotsure](https://meta.discourse.org/u/hmmmnotsure)
#### Post date: [March 2, 2025, 3:08am UTC](https://meta.discourse.org/t/how-to-purge-data-older-than-3months/352137/5 "2025-03-02T03:08:26Z")

</div>

yes, i just want last one month’s data. I dont need the rest.

---

<div class="post-metadata">

### Author: ![Canapin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/canapin/32/119591_2.png) [@Canapin](https://meta.discourse.org/u/Canapin)
#### Post date: [March 2, 2025, 10:05am UTC](https://meta.discourse.org/t/how-to-purge-data-older-than-3months/352137/6 "2025-03-02T10:05:24Z")

</div>

> [@pfaffman](#):
>
> Maybe you just want to generate some bogus data? I think there is a rake task for that

Yes, there’s a task:

> [@Set up a staging server](https://meta.discourse.org/t/set-up-a-staging-server/225951/1):
>
> ```plaintext
> ./launcher enter app
> ALLOW_DEV_POPULATE=1 bundle install
> ALLOW_DEV_POPULATE=1 rake dev:populate
> 
> ```
