pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
how to cleanup archive based on datetime
3+ messages / 3 participants
[nested] [flat]

* how to cleanup archive based on datetime
@ 2018-10-10 07:00 magodo <wztdyl@sina.com>
  2018-10-10 14:14 ` Re: how to cleanup archive based on datetime Adrian Klaver <adrian.klaver@aklaver.com>
  2018-10-10 14:23 ` Re: how to cleanup archive based on datetime Martin Marques <martin.marques@2ndquadrant.com>
  0 siblings, 2 replies; 3+ messages in thread

From: magodo @ 2018-10-10 07:00 UTC (permalink / raw)
  To: pgsql-general


Hello,

I know there is a tool `pg_archivecleanup`, but it only accepts wal
filename. What if I want to clean up all archived wal before a
specified datetime?

Though I could check the ctime fo each wal and figure out which to
remove, but it looks like not a elegent way to do this.

Also I tried to parse each wal and compare with the specified datetime
in a binary-search way, but it is based on the fact that every COMMIT
time in wal is sequential, but it looks like not the case..

Hence I wonder what is the best practice for this task?

Thank you in advance!
---
Magodo






^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: how to cleanup archive based on datetime
  2018-10-10 07:00 how to cleanup archive based on datetime magodo <wztdyl@sina.com>
@ 2018-10-10 14:14 ` Adrian Klaver <adrian.klaver@aklaver.com>
  1 sibling, 0 replies; 3+ messages in thread

From: Adrian Klaver @ 2018-10-10 14:14 UTC (permalink / raw)
  To: magodo <wztdyl@sina.com>; pgsql-general

On 10/10/18 12:00 AM, magodo wrote:
> 
> Hello,
> 
> I know there is a tool `pg_archivecleanup`, but it only accepts wal
> filename. What if I want to clean up all archived wal before a
> specified datetime?


That is dangerous, given that a WAL is important not based on its age 
but on whether it's content is still needed.

It would help to know what it is you are trying to achieve?

> 
> Though I could check the ctime fo each wal and figure out which to
> remove, but it looks like not a elegent way to do this.
> 
> Also I tried to parse each wal and compare with the specified datetime
> in a binary-search way, but it is based on the fact that every COMMIT
> time in wal is sequential, but it looks like not the case..
> 
> Hence I wonder what is the best practice for this task?
> 
> Thank you in advance!
> ---
> Magodo
> 
> 
> 
> 


-- 
Adrian Klaver
adrian.klaver@aklaver.com




^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: how to cleanup archive based on datetime
  2018-10-10 07:00 how to cleanup archive based on datetime magodo <wztdyl@sina.com>
@ 2018-10-10 14:23 ` Martin Marques <martin.marques@2ndquadrant.com>
  1 sibling, 0 replies; 3+ messages in thread

From: Martin Marques @ 2018-10-10 14:23 UTC (permalink / raw)
  To: magodo <wztdyl@sina.com>; pgsql-general

El 10/10/18 a las 04:00, magodo escribió:
> 
> Hello,
> 
> I know there is a tool `pg_archivecleanup`, but it only accepts wal
> filename. What if I want to clean up all archived wal before a
> specified datetime?
> 
> Though I could check the ctime fo each wal and figure out which to
> remove, but it looks like not a elegent way to do this.
> 
> Also I tried to parse each wal and compare with the specified datetime
> in a binary-search way, but it is based on the fact that every COMMIT
> time in wal is sequential, but it looks like not the case..
> 
> Hence I wonder what is the best practice for this task?

Don't do that manually. Install `barman` and let it take care of
removing old WALs which are not needed anyore.

Regards,

-- 
Martín Marqués                http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services




^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2018-10-10 14:23 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-10-10 07:00 how to cleanup archive based on datetime magodo <wztdyl@sina.com>
2018-10-10 14:14 ` Adrian Klaver <adrian.klaver@aklaver.com>
2018-10-10 14:23 ` Martin Marques <martin.marques@2ndquadrant.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox