How do I cleanup Postgres WAL?
&quot;pg_wal&quot; cleans itself up. You should almost never touch pg_wal by hand. If it is not cleaning itself up, you need to figure out why and fix the underlying issue.
One possible reason is that you have a replication slot which is holding it back.  Either a replica is using a slot and is unable to keep up. Or you have a slot which has no replica attached, for example you destroyed the replica but didn't drop the slop it used to occupy.  You can see what slots you have by querying pg_replication_slots, and if necessary drop one with pg_drop_replication_slot, both run on the master.  You would look for the slot with the oldest non-NULL value of &quot;restart_lsn&quot;.
Another reason is that you have &quot;archive_mode&quot; turned on, but your &quot;archive_command&quot; is constantly failing or can't keep up.  You will see warnings about this in your server log file if it is failing.
&quot;pg_archivecleanup&quot; is used to clean up a WAL archive.  &quot;pg_wal&quot; is not the archive, it is the live WAL files. You are lucky you didn't destroy your database by monkeying around in there.