Search Postgresql Archives

Re: pg_archivecleanup - Increase time files are deleted

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux