Re: Allow pg_archivecleanup to remove backup history files

Michael Paquier <michael@paquier.xyz>

From: Michael Paquier <michael@paquier.xyz>
To: Kyotaro Horiguchi <horikyota.ntt@gmail.com>
Cc: torikoshia@oss.nttdata.com, bharath.rupireddyforpostgres@gmail.com, pgsql-hackers@postgresql.org
Date: 2023-05-26T05:06:10Z
Lists: pgsql-hackers
On Fri, May 26, 2023 at 10:07:48AM +0900, Kyotaro Horiguchi wrote:
> +			if (!IsXLogFileName(walfile) && !IsPartialXLogFileName(walfile) &&
> +				(!cleanBackupHistory || !IsBackupHistoryFileName(walfile)))
> +				continue;
> 
> I'm not certain about the others, but I see this a tad tricky to
> understand at first glance. Here's how I would phrase it. (A nearby
> comment might require a tweak if we go ahead with this change.)
> 
> 		if (!(IsXLogFileName(walfile) || IsPartialXLogFileName(walfile) ||
> 			(cleanBackupHistory && IsBackupHistoryFileName(walfile))))
> or 
> 		if (!IsXLogFileName(walfile) && !IsPartialXLogFileName(walfile) &&
> 			!(cleanBackupHistory && IsBackupHistoryFileName(walfile)))

FWIW, I am OK with what's written in the patch, but it is true that
your second suggestion makes things a bit easier to read, perhaps.
--
Michael

Commits

  1. pg_archivecleanup: Add --clean-backup-history

  2. pg_archivecleanup: Refactor loop doing old segment removals

  3. Introduce long options in pg_archivecleanup