Re: Backup certain months old data

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: Siraj G <tosiraj(dot)g(at)gmail(dot)com>, pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Backup certain months old data
Date: 2024-01-23 05:25:58
Message-ID: 17ee71d1-036f-4c4d-a1ff-eb5d1f23a68e@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 1/22/24 19:11, Siraj G wrote:
> Hello!
>
> I would like to know how we can backup certain months old data from
> PgSQL and then delete it. The intent is to backup everything that is
> older than 2 quarters to a blob storage and delete it, to improve
> performance and reduce billing.

1) Postgres does not track the insert/update times of data, so unless
you have fields that track that you will not be able to do that.

2) If you do have a way of telling the times for all the records, are
you sure that removing the data on a time basis will be clean enough
operation that it will not leave the data in a compromised state?

3) Have you considered partitioning? See here:

https://www.postgresql.org/docs/current/ddl-partitioning.html

>
> Regards
> Siraj

--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message jian he 2024-01-23 05:31:00 Re: Emitting JSON to file using COPY TO
Previous Message Ron Johnson 2024-01-23 03:57:01 Re: Backup certain months old data