Pg-archivecleanup Must Specify Oldest Kept Wal File [2021] Jun 2026
To programmatically determine the oldest needed WAL on a primary:
pg_archivecleanup /var/lib/pgsql/archive 000000010000001A000000E1 pg-archivecleanup must specify oldest kept wal file
The "must specify oldest kept WAL file" error is specific to pg_archivecleanup . However, similar argument-missing errors exist in other PostgreSQL utilities: To programmatically determine the oldest needed WAL on
For replication, the standby can use pg_archivecleanup as part of restore_command . Note: pg_archivecleanup alone does not fetch WALs. using dry-run options
$ pg_archivecleanup /mnt/wal_archive pg_archivecleanup: must specify oldest kept WAL file
By understanding the role of pg_archivecleanup —deleting archived WAL files older than a specified segment—you can easily resolve the error by providing the correct WAL filename. More importantly, you can prevent it by implementing robust scripting practices: validating arguments, using dry-run options, and integrating cleanup with backup and replication policies.