Re: pg_archivecleanup - Increase time files are deleted

From: Patrick B <patrickbakerbr(at)gmail(dot)com>
To: Melvin Davidson <melvin6925(at)gmail(dot)com>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: pg_archivecleanup - Increase time files are deleted
Date: 2016-06-26 23:38:36
Message-ID: CAJNY3iskgN7b3QNgFCwD8QSXc4dwFPq7PHZwBLB3oKLdEkCo3g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Apparently I can't do that via Postgres.

So I've made a bash script to do the work for me.

The script will only delete the wal_files older than 24h ( -mmin +1440 )

* It has been tested and it's working.

*recovery.conf:*

> archive_cleanup_command = 'exec nice -n 19 ionice -c 2 -n 7
> ../archivecleaup_mv.bash -d "../wal_archive" "%r"'

*archivecleaup_mv.bash:*

#!/bin/bash -eu

declare -r -x PATH='/usr/local/bin:/usr/bin:/bin';

ARCHIVEDIR='/var/lib/pgsql/9.2/wal_archive/'
CHKPOINT=$(find $ARCHIVEDIR -type f -mmin +1440 -name '00*' -printf '%f\n'
| sort -r | head -1)
#cd $ARCHIVEDIR

exec "/usr/pgsql-9.2/bin/pg_archivecleanup" $ARCHIVEDIR $CHKPOINT;
find $ARCHIVEDIR -type f -mmin +1440 -a -name '00*' -a ! -newer $CHKPOINT
-delete

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Ian Barwick 2016-06-26 23:39:13 Re: pg_archivecleanup - Increase time files are deleted
Previous Message Melvin Davidson 2016-06-26 21:42:33 Re: pg_archivecleanup - Increase time files are deleted