The default value for
wal_keep_segments to a value greater than zero, it's possible to force PostgreSQL to maintain a minimum amount of WAL files on the local server. This can be useful when e.g. executing
pg_basebackup to create a copy of the server to ensure that changes made since the start of the backup can be fetched after the backup has completed, or to try and prevent a situation where if a standby is unable to connect to the primary or upstream node, it can still retrieve a sufficient amount of WAL to catch up.
However this is not a reliable method of WAL retention as it is difficult or even impossible to set a value sufficiently high enough to cover all possible cases where WAL might need to be retrieved, without running the risk of exhausting storage space on the local server. A more reliable solution usually involves replication slots and a WAL archive.