Tuesday 5 October 2010

Cleaning your archive

Whether you're thinking of using PostgreSQL 9.0 yet or not, you maybe interested in a small new utility that is designed to help you clean out old WAL archive files.

pg_archivecleanup is a standalone program which simply removes all WAL files older than a certain filename. You could use it like this:

pg_archivecleanup /my/archive 000000010000DEAD0000BEEF

The good thing here is that the tool works just fine for any release of PostgreSQL, not just 9.0. Mostly useful for bash or Windows scripts, since people will no doubt confirm it's trivial to do this in Python or perl etc..

The utility was designed as a dual purpose tool, since with 9.0 pg_standby is no longer required, yet you still need some way to clear down an archive. So you can also include it in the archive_cleanup_command, like so

archive_cleanup_command = 'pg_archivecleanup /my/archive %r'

which gets called regularly with changing values of %r to clean out your archive directories.

Not big, but its useful.

No comments:

Post a Comment